NimaKL's picture
3.1.0a0
822f42f
import streamlit as st
from transformers import pipeline
from textblob import TextBlob
import pandas as pd
import pkg_resources
pkg_resources.require("googletrans==3.1.0a0")
from googletrans import Translator
translator = Translator()
import os
import openai
openai.api_key = "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"
pipe = pipeline('summarization')
st.title("Turkish Passive Summarization")
#Textbox for text user is entering
st.subheader("Enter the text you'd like to analyze.")
text = st.text_input('Enter text') #text is stored in this variable
# Girdi Metnini İngilizce'ye Çevirme
ttext = translator.translate(text, dest='en')
ttext = ttext.text
# Özetleme İşlemini Başlatma
tResponse = openai.Completion.create(
model="text-davinci-002",
prompt="Summarize this for a second-grade student: " + ttext,
temperature=0.7,
max_tokens=256,
top_p=1,
frequency_penalty=0,
presence_penalty=0
)
# Üçüncü kişi
response = openai.Completion.create(
model="text-davinci-002",
prompt="Convert this from first-person to third person (gender female):\n\n"
+tResponse['choices'][0]['text'],
temperature=0,
max_tokens=60,
top_p=1,
frequency_penalty=0,
presence_penalty=0
)
# Çıkan İngilizce Sonucu Elde Etme
ftext = response['choices'][0]['text']
# İngilizce Özet
# İngilizce metni Türkçe'ye çevirme
result = translator.translate(ftext, dest='tr')
result = result.text
print("\nTürkçe Özet:\n\n",result)