Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -15,19 +15,58 @@ CATEGORIES = ["Pricing", "Feature", "Customer Service", "Delivery", "Quality"]
|
|
15 |
# Define the fixed confidence threshold
|
16 |
CONFIDENCE_THRESHOLD = 0.8
|
17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
# Streamlit app UI
|
19 |
-
|
20 |
st.markdown(
|
21 |
"""
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
|
|
|
|
|
|
|
|
27 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
)
|
29 |
|
30 |
-
# Input text box for customer feedback
|
31 |
feedback_input = st.text_area(
|
32 |
"Enter customer feedback:",
|
33 |
placeholder="Type your feedback here...",
|
@@ -90,7 +129,7 @@ if st.button("Classify Feedback"):
|
|
90 |
st.subheader("Categorized Feedback with Sentiment Analysis")
|
91 |
found_categories = False
|
92 |
|
93 |
-
for category, results in category_results.items():
|
94 |
if results: # If the category has any sentences
|
95 |
found_categories = True
|
96 |
st.write(f"### **{category}**")
|
@@ -104,7 +143,9 @@ if st.button("Classify Feedback"):
|
|
104 |
f"(Score: {result['sentiment_score']})",
|
105 |
unsafe_allow_html=True
|
106 |
)
|
107 |
-
|
|
|
|
|
108 |
|
109 |
if not found_categories:
|
110 |
st.warning("No categories met the confidence threshold of 0.8.")
|
|
|
15 |
# Define the fixed confidence threshold
|
16 |
CONFIDENCE_THRESHOLD = 0.8
|
17 |
|
18 |
+
# Custom CSS for background colors
|
19 |
+
st.markdown(
|
20 |
+
"""
|
21 |
+
<style>
|
22 |
+
/* Background color for the title */
|
23 |
+
.title-container {
|
24 |
+
background-color: #e6f3ff; /* Light blue background */
|
25 |
+
padding: 10px;
|
26 |
+
border-radius: 5px;
|
27 |
+
}
|
28 |
+
/* Background color for the description (st.markdown) */
|
29 |
+
.description-container {
|
30 |
+
background-color: #f0f0f0; /* Light gray background */
|
31 |
+
padding: 10px;
|
32 |
+
border-radius: 5px;
|
33 |
+
}
|
34 |
+
/* Background color for the text area (feedback_input) */
|
35 |
+
.stTextArea textarea {
|
36 |
+
background-color: #fff5e6; /* Light peach background */
|
37 |
+
border-radius: 5px;
|
38 |
+
}
|
39 |
+
</style>
|
40 |
+
""",
|
41 |
+
unsafe_allow_html=True
|
42 |
+
)
|
43 |
+
|
44 |
# Streamlit app UI
|
45 |
+
# Title with icon
|
46 |
st.markdown(
|
47 |
"""
|
48 |
+
<div class="title-container">
|
49 |
+
<h1>📢 Customer Feedback Categorization with Sentiment Analysis</h1>
|
50 |
+
</div>
|
51 |
+
""",
|
52 |
+
unsafe_allow_html=True
|
53 |
+
)
|
54 |
+
|
55 |
+
# Description with background color
|
56 |
+
st.markdown(
|
57 |
"""
|
58 |
+
<div class="description-container">
|
59 |
+
This app uses Hugging Face models to detect the topics and intent of customer feedback
|
60 |
+
and determine the sentiment (positive or negative) for each relevant category.
|
61 |
+
A single feedback may belong to multiple categories, such as Pricing, Feature, and Customer Service.
|
62 |
+
The feedback is split into sentences, and each sentence is categorized and analyzed for sentiment.
|
63 |
+
Only categories with a confidence score >= 0.8 are displayed.
|
64 |
+
</div>
|
65 |
+
""",
|
66 |
+
unsafe_allow_html=True
|
67 |
)
|
68 |
|
69 |
+
# Input text box for customer feedback with background color
|
70 |
feedback_input = st.text_area(
|
71 |
"Enter customer feedback:",
|
72 |
placeholder="Type your feedback here...",
|
|
|
129 |
st.subheader("Categorized Feedback with Sentiment Analysis")
|
130 |
found_categories = False
|
131 |
|
132 |
+
for i, (category, results) in enumerate(category_results.items()):
|
133 |
if results: # If the category has any sentences
|
134 |
found_categories = True
|
135 |
st.write(f"### **{category}**")
|
|
|
143 |
f"(Score: {result['sentiment_score']})",
|
144 |
unsafe_allow_html=True
|
145 |
)
|
146 |
+
# Add a horizontal divider after each category (except the last one)
|
147 |
+
if i < len(category_results) - 1 and any(category_results[cat] for cat in list(category_results.keys())[i+1:]):
|
148 |
+
st.markdown("---") # Horizontal line to separate categories
|
149 |
|
150 |
if not found_categories:
|
151 |
st.warning("No categories met the confidence threshold of 0.8.")
|