boompack commited on
Commit
895ca00
·
verified ·
1 Parent(s): 6e3f65c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -9
app.py CHANGED
@@ -25,18 +25,23 @@ def parse_comments(raw_text):
25
 
26
  return results
27
 
28
- # Входные данные
29
- raw_text = """alormusicgroupKeep going‼️‼️1 нед.Нравится: 1ОтветитьПоказать переводДействия с комментариемНравитсяСкрыть ответыjfk_4president@alormusicgroup Big facts 🫡🫡🦾1 нед.ОтветитьПоказать переводДействия с комментариемНравится..."""
 
 
 
 
 
 
30
 
31
- # Вывод
32
- parsed_comments = parse_comments(raw_text)
33
- for comment in parsed_comments:
34
- print(comment)
35
 
36
- # Настройка Gradio интерфейса
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