boompack
commited on
Commit
·
b4bbaee
verified
·
0
Parent(s):
initial commit
Browse files- .gitattributes +35 -0
- README.md +14 -0
- app.py +54 -0
- requirements.txt +1 -0
.gitattributes
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: New Space
|
3 |
+
emoji: 💻
|
4 |
+
colorFrom: yellow
|
5 |
+
colorTo: pink
|
6 |
+
sdk: gradio
|
7 |
+
sdk_version: 5.4.0
|
8 |
+
app_file: app.py
|
9 |
+
pinned: false
|
10 |
+
license: afl-3.0
|
11 |
+
short_description: muza
|
12 |
+
---
|
13 |
+
|
14 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import re
|
3 |
+
|
4 |
+
# Функция для анализа поста
|
5 |
+
def analyze_post(description, likes, comments, likes_on_comments, all_comments):
|
6 |
+
# Количественный анализ
|
7 |
+
total_likes = int(likes)
|
8 |
+
total_comments = int(comments)
|
9 |
+
total_likes_on_comments = int(likes_on_comments)
|
10 |
+
|
11 |
+
# Расчет средней вовлеченности
|
12 |
+
avg_likes_per_comment = total_likes_on_comments / total_comments if total_comments > 0 else 0
|
13 |
+
|
14 |
+
# Обновленное регулярное выражение для извлечения никнейма, комментария и лайков
|
15 |
+
pattern = r"Фото профиля (\S+)\n(.+?)\n\d+ (?:ч|дн)\.(?:\"Нравится\": (\d+))?(?:Ответить)?"
|
16 |
+
matches = re.findall(pattern, all_comments)
|
17 |
+
|
18 |
+
# Форматируем выводы
|
19 |
+
users_output = "\n".join([match[0] for match in matches]) # Никнеймы
|
20 |
+
comments_output = "\n".join([match[1] for match in matches]) # Комментарии
|
21 |
+
|
22 |
+
# Output 3: Лайки по хронологии
|
23 |
+
likes_chronology_output = "\n".join([match[2] if match[2] else "0" for match in matches])
|
24 |
+
|
25 |
+
# Output 4: Общая сумма лайков на всех комментариях
|
26 |
+
total_likes_sum = sum(int(match[2]) for match in matches if match[2])
|
27 |
+
|
28 |
+
# Итоговый вывод
|
29 |
+
result = (
|
30 |
+
f"Описание поста: {description}\n"
|
31 |
+
f"Количество лайков: {total_likes}\n"
|
32 |
+
f"Количество комментариев: {total_comments}\n"
|
33 |
+
f"Среднее количество лайков на комментарий: {avg_likes_per_comment:.2f}\n"
|
34 |
+
)
|
35 |
+
|
36 |
+
return result, users_output, comments_output, likes_chronology_output, total_likes_sum
|
37 |
+
|
38 |
+
# Создаем интерфейс Gradio
|
39 |
+
iface = gr.Interface(
|
40 |
+
fn=analyze_post,
|
41 |
+
inputs=[
|
42 |
+
gr.Textbox(label="Описание поста", placeholder="Введите описание поста..."),
|
43 |
+
gr.Number(label="Количество лайков"),
|
44 |
+
gr.Number(label="Количество комментариев"),
|
45 |
+
gr.Number(label="Количество лайков на комментарии"),
|
46 |
+
gr.Textbox(label="Все комментарии", placeholder="Введите комментарии в формате, как указано в примере")
|
47 |
+
],
|
48 |
+
outputs=["text", "text", "text", "text", "number"],
|
49 |
+
title="Анализ Instagram-поста",
|
50 |
+
description="Введите данные о посте в Instagram для анализа. Формат комментариев: 'Фото профиля [ник]\n[комментарий]\n[время]\"Нравится\": [число]Ответить'"
|
51 |
+
)
|
52 |
+
|
53 |
+
# Запуск приложения
|
54 |
+
iface.launch()
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
# No additional packages required as gradio is already installed.
|