Update app.py
Browse files
app.py
CHANGED
@@ -25,18 +25,23 @@ def parse_comments(raw_text):
|
|
25 |
|
26 |
return results
|
27 |
|
28 |
-
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
-
|
32 |
-
parsed_comments = parse_comments(raw_text)
|
33 |
-
|
34 |
-
print(comment)
|
35 |
|
36 |
-
|
37 |
iface = gr.Interface(
|
38 |
-
fn=process_text,
|
39 |
-
inputs=gr.Textbox(lines=10, placeholder="Введите текст сюда..."),
|
40 |
outputs=gr.Textbox(lines=10, placeholder="Результат...")
|
41 |
)
|
42 |
|
|
|
25 |
|
26 |
return results
|
27 |
|
28 |
+
def format_output(parsed_comments):
|
29 |
+
# Форматируем вывод в текстовом формате
|
30 |
+
formatted_output = ""
|
31 |
+
for comment in parsed_comments:
|
32 |
+
formatted_output += f"Пользователь: {comment['Пользователь']}\n"
|
33 |
+
formatted_output += f"Текст: {comment['Текст']}\n"
|
34 |
+
formatted_output += f"Лайков: {comment['Лайков']}\n\n"
|
35 |
+
return formatted_output
|
36 |
|
37 |
+
def process_text(raw_text):
|
38 |
+
parsed_comments = parse_comments(raw_text)
|
39 |
+
return format_output(parsed_comments)
|
|
|
40 |
|
41 |
+
# Настройка Gradio интерфейса
|
42 |
iface = gr.Interface(
|
43 |
+
fn=process_text,
|
44 |
+
inputs=gr.Textbox(lines=10, placeholder="Введите текст сюда..."),
|
45 |
outputs=gr.Textbox(lines=10, placeholder="Результат...")
|
46 |
)
|
47 |
|