Spaces:
Sleeping
Sleeping
alpcansoydas
commited on
Commit
•
5f188cd
1
Parent(s):
4c09b8d
Upload app.py
Browse files
app.py
CHANGED
@@ -22,7 +22,7 @@ Please carefully read the following text. The text is written in {LANG} language
|
|
22 |
{TEXT}
|
23 |
</text>
|
24 |
|
25 |
-
After reading it, I want you to extract topic informations from text.
|
26 |
'''
|
27 |
|
28 |
template_json = '''
|
@@ -33,7 +33,7 @@ Your task is to read the following text, convert it to json format using 'Answer
|
|
33 |
|
34 |
Your final response MUST contain only the response, no other text.
|
35 |
Example:
|
36 |
-
{{"Answer":"Sport, Entertainment"}}
|
37 |
'''
|
38 |
json_output_parser = JsonOutputParser()
|
39 |
|
@@ -44,6 +44,14 @@ def classify_text(text):
|
|
44 |
start = time.time()
|
45 |
lang = detect(text)
|
46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
prompt_classify = PromptTemplate(
|
48 |
template=template_classify,
|
49 |
input_variables=["LANG", "TEXT"]
|
@@ -72,7 +80,7 @@ def gradio_app(text):
|
|
72 |
def create_gradio_interface():
|
73 |
with gr.Blocks() as iface:
|
74 |
text_input = gr.Textbox(label="Text")
|
75 |
-
output_text = gr.Textbox(label="
|
76 |
time_taken = gr.Textbox(label="Time Taken (seconds)")
|
77 |
submit_btn = gr.Button("Classify")
|
78 |
|
|
|
22 |
{TEXT}
|
23 |
</text>
|
24 |
|
25 |
+
After reading it, I want you to extract topic informations from text in {LANG} language.
|
26 |
'''
|
27 |
|
28 |
template_json = '''
|
|
|
33 |
|
34 |
Your final response MUST contain only the response, no other text.
|
35 |
Example:
|
36 |
+
{{"Answer":["Sport", "Entertainment", "General", "Inflation", "Effects of Inflation"]]}}
|
37 |
'''
|
38 |
json_output_parser = JsonOutputParser()
|
39 |
|
|
|
44 |
start = time.time()
|
45 |
lang = detect(text)
|
46 |
|
47 |
+
language_map = {"tr": "turkish",
|
48 |
+
"en": "english",
|
49 |
+
"ar": "arabic",
|
50 |
+
"es": "spanish",
|
51 |
+
"it": "italian",
|
52 |
+
}
|
53 |
+
lang = language_map[lang]
|
54 |
+
|
55 |
prompt_classify = PromptTemplate(
|
56 |
template=template_classify,
|
57 |
input_variables=["LANG", "TEXT"]
|
|
|
80 |
def create_gradio_interface():
|
81 |
with gr.Blocks() as iface:
|
82 |
text_input = gr.Textbox(label="Text")
|
83 |
+
output_text = gr.Textbox(label="Topics")
|
84 |
time_taken = gr.Textbox(label="Time Taken (seconds)")
|
85 |
submit_btn = gr.Button("Classify")
|
86 |
|