Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -57,9 +57,22 @@ def extract_aspects(text, model):
|
|
57 |
|
58 |
def plot_sentiment_distribution(df):
|
59 |
fig, ax = plt.subplots()
|
60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
autopct='%1.1f%%',
|
62 |
-
colors=['#ff9999','#66b3ff','#99ff99'],
|
63 |
ax=ax
|
64 |
)
|
65 |
ax.set_ylabel('')
|
|
|
57 |
|
58 |
def plot_sentiment_distribution(df):
|
59 |
fig, ax = plt.subplots()
|
60 |
+
|
61 |
+
# Get counts for all possible ratings
|
62 |
+
counts = df['label'].value_counts()
|
63 |
+
|
64 |
+
# Ensure all rating categories are present (even with 0 counts)
|
65 |
+
for rating in RATING_MAP.values():
|
66 |
+
if rating not in counts.index:
|
67 |
+
counts[rating] = 0
|
68 |
+
|
69 |
+
# Sort by the predefined rating order
|
70 |
+
counts = counts.loc[list(RATING_MAP.values())]
|
71 |
+
|
72 |
+
# Plot with consistent colors
|
73 |
+
counts.plot.pie(
|
74 |
autopct='%1.1f%%',
|
75 |
+
colors=['#ff9999','#66b3ff','#99ff99'], # Negative, Neutral, Positive
|
76 |
ax=ax
|
77 |
)
|
78 |
ax.set_ylabel('')
|