Spaces:
Runtime error
Runtime error
GenaroRocha
commited on
Commit
•
b84e21c
1
Parent(s):
9a3d8a9
Making it look beautiful and reducing the batch
Browse files
app.py
CHANGED
@@ -45,7 +45,7 @@ def analyze_sentiment(text):
|
|
45 |
|
46 |
def sentiment_counts_by_category(category):
|
47 |
df_category = load_reviews(category)
|
48 |
-
df_category = df_category.head(
|
49 |
# Aplica la función de análisis de sentimientos modificada
|
50 |
df_category['sentiment'] = df_category['reviewText'].apply(analyze_sentiment)
|
51 |
# Llama a la función de trazado y devuelve el gráfico
|
@@ -58,12 +58,20 @@ def show_first_five(category):
|
|
58 |
|
59 |
# Crear la interfaz usando gr.Blocks
|
60 |
with gr.Blocks() as demo:
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
with gr.Row():
|
62 |
category = gr.Dropdown(choices=list(category_to_file_path.keys()), label="Seleccione una categoría")
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
|
|
|
|
67 |
|
68 |
show_button.click(show_first_five, inputs=category, outputs=output_df)
|
69 |
plot_button.click(sentiment_counts_by_category, inputs=category, outputs=output_plot)
|
|
|
45 |
|
46 |
def sentiment_counts_by_category(category):
|
47 |
df_category = load_reviews(category)
|
48 |
+
df_category = df_category.head(30)
|
49 |
# Aplica la función de análisis de sentimientos modificada
|
50 |
df_category['sentiment'] = df_category['reviewText'].apply(analyze_sentiment)
|
51 |
# Llama a la función de trazado y devuelve el gráfico
|
|
|
58 |
|
59 |
# Crear la interfaz usando gr.Blocks
|
60 |
with gr.Blocks() as demo:
|
61 |
+
gr.Markdown(
|
62 |
+
'''
|
63 |
+
<h1 style='text-align: center; color: navy;'>Análisis de Sentimientos Amazon</h1>
|
64 |
+
<p style='text-align: center;'>Seleccione una categoría y visualice los datos y la distribución de sentimientos.</p>
|
65 |
+
'''
|
66 |
+
)
|
67 |
with gr.Row():
|
68 |
category = gr.Dropdown(choices=list(category_to_file_path.keys()), label="Seleccione una categoría")
|
69 |
+
with gr.Column():
|
70 |
+
show_button = gr.Button("Mostrar Datos", style="width: 100%;")
|
71 |
+
plot_button = gr.Button("Graficar Distribución de Sentimientos", style="width: 100%;")
|
72 |
+
with gr.Column():
|
73 |
+
output_df = gr.Dataframe()
|
74 |
+
output_plot = gr.Plot()
|
75 |
|
76 |
show_button.click(show_first_five, inputs=category, outputs=output_df)
|
77 |
plot_button.click(sentiment_counts_by_category, inputs=category, outputs=output_plot)
|