Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -40,33 +40,42 @@ def classify_comments(categories):
|
|
| 40 |
|
| 41 |
# Gradio Interface
|
| 42 |
with gr.Blocks() as nps:
|
| 43 |
-
#
|
| 44 |
-
|
| 45 |
|
| 46 |
-
#
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
|
|
|
| 51 |
|
| 52 |
-
#
|
| 53 |
-
def reset_categories():
|
| 54 |
-
return [], "**Categories:**\n- None"
|
| 55 |
-
|
| 56 |
-
# UI for adding categories
|
| 57 |
with gr.Row():
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
|
| 63 |
-
#
|
| 64 |
-
uploaded_file = gr.File(label="Upload CSV", type="filepath")
|
| 65 |
template_btn = gr.Button("Use Template")
|
| 66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
# Classify button
|
| 69 |
-
classify_btn = gr.Button("Classify
|
|
|
|
|
|
|
| 70 |
output = gr.HTML()
|
| 71 |
|
| 72 |
# Function to load data from uploaded CSV
|
|
|
|
| 40 |
|
| 41 |
# Gradio Interface
|
| 42 |
with gr.Blocks() as nps:
|
| 43 |
+
# App title
|
| 44 |
+
gr.Markdown("# Customer Comment Classifier")
|
| 45 |
|
| 46 |
+
# Short explanation
|
| 47 |
+
gr.Markdown("""
|
| 48 |
+
This app classifies customer comments into categories and assigns sentiment labels (Positive/Negative).
|
| 49 |
+
You can upload your own dataset or use the provided template. The app will append the generated
|
| 50 |
+
`comment_sentiment` and `comment_category` fields to your dataset.
|
| 51 |
+
""")
|
| 52 |
|
| 53 |
+
# File upload and instructions
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
with gr.Row():
|
| 55 |
+
with gr.Column(scale=1):
|
| 56 |
+
uploaded_file = gr.File(label="Upload CSV", type="filepath", scale=1)
|
| 57 |
+
with gr.Column(scale=2):
|
| 58 |
+
gr.Markdown("""
|
| 59 |
+
**Instructions:**
|
| 60 |
+
- Upload a CSV file with at least one column: `customer_comment`.
|
| 61 |
+
- If you don't have your own data, click **Use Template** to load a sample dataset.
|
| 62 |
+
""")
|
| 63 |
|
| 64 |
+
# Template button
|
|
|
|
| 65 |
template_btn = gr.Button("Use Template")
|
| 66 |
+
|
| 67 |
+
# Category widgets
|
| 68 |
+
with gr.Row():
|
| 69 |
+
with gr.Column():
|
| 70 |
+
category_input = gr.Textbox(label="New Category", placeholder="Enter category name")
|
| 71 |
+
add_category_btn = gr.Button("Add Category")
|
| 72 |
+
reset_btn = gr.Button("Reset Categories")
|
| 73 |
+
category_status = gr.Markdown("**Categories:**\n- None")
|
| 74 |
|
| 75 |
# Classify button
|
| 76 |
+
classify_btn = gr.Button("Classify", size="sm")
|
| 77 |
+
|
| 78 |
+
# Output
|
| 79 |
output = gr.HTML()
|
| 80 |
|
| 81 |
# Function to load data from uploaded CSV
|