Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -34,21 +34,23 @@ def index():
|
|
34 |
sentiment_count = None
|
35 |
|
36 |
current_directory = os.getcwd()
|
37 |
-
print("
|
38 |
|
39 |
if request.method == "POST":
|
40 |
url = request.form["url"]
|
41 |
if url:
|
|
|
42 |
video_details = clustering.get_youtube_video_details(url, api_key)
|
43 |
comments_df = clustering.get_youtube_comments(api_key, url)
|
|
|
44 |
comments_df = clustering.add_normalized_embeddings_to_dataframe(
|
45 |
comments_df, "comment"
|
46 |
)
|
47 |
-
|
48 |
comments_df["published_at"] = pd.to_datetime(
|
49 |
comments_df["published_at"]
|
50 |
).dt.date
|
51 |
-
|
52 |
comments_df = clustering.classify_sentiment_df(comments_df)
|
53 |
comments_df.to_pickle(
|
54 |
"./data/Comentarios-Youtube/comments_df.pkl"
|
@@ -64,14 +66,14 @@ def index():
|
|
64 |
umap_df, min_eps, max_eps = clustering.transform_embeddings(
|
65 |
comments_df, embeddings_col="embeddings"
|
66 |
)
|
67 |
-
|
68 |
image_path = os.path.join("static", "wordcloud.png")
|
69 |
clustering.plot_wordcloud(comments_df, text_column="comment", output_filename=image_path)
|
70 |
|
71 |
total = comments_df.shape[0]
|
72 |
-
|
73 |
min_items_by_cluster = clustering.determine_min_items_by_cluster(total)
|
74 |
-
|
75 |
(
|
76 |
cluster_assignments,
|
77 |
cluster_counts,
|
@@ -84,7 +86,7 @@ def index():
|
|
84 |
threshold_values=[0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9],
|
85 |
embeddings_col="embeddings"
|
86 |
)
|
87 |
-
|
88 |
labels, source, target, values, comments = clustering.build_sankey_data(
|
89 |
cluster_assignments,
|
90 |
cluster_counts,
|
|
|
34 |
sentiment_count = None
|
35 |
|
36 |
current_directory = os.getcwd()
|
37 |
+
print("Iniciando procesamiento...")
|
38 |
|
39 |
if request.method == "POST":
|
40 |
url = request.form["url"]
|
41 |
if url:
|
42 |
+
print("Obteniendo datos")
|
43 |
video_details = clustering.get_youtube_video_details(url, api_key)
|
44 |
comments_df = clustering.get_youtube_comments(api_key, url)
|
45 |
+
print("Generando embeddings")
|
46 |
comments_df = clustering.add_normalized_embeddings_to_dataframe(
|
47 |
comments_df, "comment"
|
48 |
)
|
49 |
+
print("Procesamiento de los datos")
|
50 |
comments_df["published_at"] = pd.to_datetime(
|
51 |
comments_df["published_at"]
|
52 |
).dt.date
|
53 |
+
print("Clasificaci贸n de los sentimientos")
|
54 |
comments_df = clustering.classify_sentiment_df(comments_df)
|
55 |
comments_df.to_pickle(
|
56 |
"./data/Comentarios-Youtube/comments_df.pkl"
|
|
|
66 |
umap_df, min_eps, max_eps = clustering.transform_embeddings(
|
67 |
comments_df, embeddings_col="embeddings"
|
68 |
)
|
69 |
+
print("Generaci贸n de wordcloud")
|
70 |
image_path = os.path.join("static", "wordcloud.png")
|
71 |
clustering.plot_wordcloud(comments_df, text_column="comment", output_filename=image_path)
|
72 |
|
73 |
total = comments_df.shape[0]
|
74 |
+
print("Evaluaci贸n de m茅tricas")
|
75 |
min_items_by_cluster = clustering.determine_min_items_by_cluster(total)
|
76 |
+
print("Modelado")
|
77 |
(
|
78 |
cluster_assignments,
|
79 |
cluster_counts,
|
|
|
86 |
threshold_values=[0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9],
|
87 |
embeddings_col="embeddings"
|
88 |
)
|
89 |
+
print("Creaci贸n de gr谩fico de Sankey")
|
90 |
labels, source, target, values, comments = clustering.build_sankey_data(
|
91 |
cluster_assignments,
|
92 |
cluster_counts,
|