Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,9 +1,47 @@
|
|
1 |
import streamlit as st
|
2 |
from transformers import pipeline
|
3 |
from textblob import TextBlob
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
pipe = pipeline('summarization')
|
6 |
st.title("Turkish Passive Summarization")
|
7 |
#Textbox for text user is entering
|
8 |
st.subheader("Enter the text you'd like to analyze.")
|
9 |
-
text = st.text_input('Enter text') #text is stored in this variable
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
from transformers import pipeline
|
3 |
from textblob import TextBlob
|
4 |
+
import pandas as pd
|
5 |
+
from googletrans import Translator
|
6 |
+
translator = Translator()
|
7 |
+
import os
|
8 |
+
import openai
|
9 |
+
openai.api_key = "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"
|
10 |
|
11 |
pipe = pipeline('summarization')
|
12 |
st.title("Turkish Passive Summarization")
|
13 |
#Textbox for text user is entering
|
14 |
st.subheader("Enter the text you'd like to analyze.")
|
15 |
+
text = st.text_input('Enter text') #text is stored in this variable
|
16 |
+
|
17 |
+
# Girdi Metnini İngilizce'ye Çevirme
|
18 |
+
ttext = translator.translate(text, dest='en')
|
19 |
+
ttext = ttext.text
|
20 |
+
# Özetleme İşlemini Başlatma
|
21 |
+
tResponse = openai.Completion.create(
|
22 |
+
model="text-davinci-002",
|
23 |
+
prompt="Summarize this for a second-grade student: " + ttext,
|
24 |
+
temperature=0.7,
|
25 |
+
max_tokens=256,
|
26 |
+
top_p=1,
|
27 |
+
frequency_penalty=0,
|
28 |
+
presence_penalty=0
|
29 |
+
)
|
30 |
+
# Üçüncü kişi
|
31 |
+
response = openai.Completion.create(
|
32 |
+
model="text-davinci-002",
|
33 |
+
prompt="Convert this from first-person to third person (gender female):\n\n"
|
34 |
+
+tResponse['choices'][0]['text'],
|
35 |
+
temperature=0,
|
36 |
+
max_tokens=60,
|
37 |
+
top_p=1,
|
38 |
+
frequency_penalty=0,
|
39 |
+
presence_penalty=0
|
40 |
+
)
|
41 |
+
# Çıkan İngilizce Sonucu Elde Etme
|
42 |
+
ftext = response['choices'][0]['text']
|
43 |
+
# İngilizce Özet
|
44 |
+
# İngilizce metni Türkçe'ye çevirme
|
45 |
+
result = translator.translate(ftext, dest='tr')
|
46 |
+
result = result.text
|
47 |
+
print("\nTürkçe Özet:\n\n",result)
|