File size: 1,491 Bytes
80f656c
 
 
fddc85c
96cf951
822f42f
fddc85c
 
 
 
 
80f656c
905dca8
80f656c
 
 
fddc85c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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)