boompack commited on
Commit
a539744
·
verified ·
1 Parent(s): 5be6938

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -10
app.py CHANGED
@@ -7,6 +7,7 @@ import logging
7
  import html
8
  from uuid import uuid4
9
  import torch
 
10
 
11
  # Настройка логирования
12
  logging.basicConfig(
@@ -184,16 +185,24 @@ class InstagramCommentAnalyzer:
184
  except Exception as e:
185
  logger.error(f"Error processing comments: {str(e)}")
186
  return ["[ОШИБКА ОБРАБОТКИ КОММЕНТАРИЕВ]"]
187
- def main():
188
- example_text = """
189
- user1 2 нед. This is a positive comment! Отметки "Нравится": 25
190
- user2 3 нед. This is a negative comment! Отметки "Нравится": 5
191
- """
192
 
 
 
193
  analyzer = InstagramCommentAnalyzer()
194
- formatted_comments = analyzer.process_comments(example_text)
195
- for formatted_comment in formatted_comments:
196
- print(formatted_comment)
197
 
198
- if __name__ == "__main__":
199
- main()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  import html
8
  from uuid import uuid4
9
  import torch
10
+ import gradio as gr
11
 
12
  # Настройка логирования
13
  logging.basicConfig(
 
185
  except Exception as e:
186
  logger.error(f"Error processing comments: {str(e)}")
187
  return ["[ОШИБКА ОБРАБОТКИ КОММЕНТАРИЕВ]"]
 
 
 
 
 
188
 
189
+ # Создание интерфейса Gradio
190
+ def create_interface():
191
  analyzer = InstagramCommentAnalyzer()
 
 
 
192
 
193
+ def analyze_text(text: str):
194
+ formatted_comments = analyzer.process_comments(text)
195
+ return "\n".join(formatted_comments)
196
+
197
+ iface = gr.Interface(
198
+ fn=analyze_text,
199
+ inputs=gr.Textbox(lines=10, placeholder="Вставьте текст комментариев здесь..."),
200
+ outputs=gr.Textbox(lines=20, placeholder="Результаты анализа будут отображены здесь..."),
201
+ title="Instagram Comment Analyzer",
202
+ description="Введите текст комментариев из Instagram для анализа настроений и извлечения информации.",
203
+ )
204
+ return iface
205
+
206
+ def main():
207
+ # Запуск интерфейса Gradio
208
+