Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,31 +11,22 @@ import plotly.express as px
|
|
| 11 |
from PIL import Image
|
| 12 |
|
| 13 |
categories_keywords = {
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
"Online Meetings": ["meeting", "meeting code", "passcode", "join meeting", "zoom", "zoom link"],
|
| 31 |
-
"Event Inquiries": ["event", "webinar", "meeting", "conference", "session", "seminar", "workshop", "invitation"],
|
| 32 |
-
"Payment Issues": ["payment", "billing", "transaction", "charge", "fee", "invoice", "refund", "receipt"],
|
| 33 |
-
"Registration Issues": ["registration", "register", "sign up", "enroll", "join", "signup", "enrollment"],
|
| 34 |
-
"Service Requests": ["service", "support", "request", "assistance", "help", "aid", "maintenance"],
|
| 35 |
-
"Account Issues": ["account", "profile", "update", "activation", "deactivation", "credentials", "reset"],
|
| 36 |
-
"Product Information": ["product", "service", "details", "info", "information", "specifications", "features"],
|
| 37 |
-
"Order Status": ["order", "status", "tracking", "shipment", "delivery", "purchase", "dispatch"],
|
| 38 |
-
"Miscellaneous": []
|
| 39 |
}
|
| 40 |
|
| 41 |
|
|
@@ -169,43 +160,41 @@ def generate_bar_chart(df, num_clusters_to_display):
|
|
| 169 |
img = Image.open(buf)
|
| 170 |
return img
|
| 171 |
|
| 172 |
-
def main(file,
|
| 173 |
try:
|
| 174 |
df = pd.read_csv(file)
|
| 175 |
|
|
|
|
|
|
|
| 176 |
|
| 177 |
df = preprocess_data(df)
|
| 178 |
-
|
| 179 |
-
df = df[df['Category'] != 'Miscellaneous']
|
| 180 |
|
| 181 |
-
# Get category sizes and sort by size in
|
| 182 |
category_sizes = df['Category'].value_counts().reset_index()
|
| 183 |
category_sizes.columns = ['Category', 'Count']
|
| 184 |
-
sorted_categories = category_sizes.sort_values(by='Count', ascending=
|
| 185 |
-
sorted_categories_sm = category_sizes.sort_values(by='Count', ascending=True)['Category'].tolist()
|
| 186 |
-
|
| 187 |
|
| 188 |
-
# Get the largest x categories as specified by
|
| 189 |
-
largest_categories = sorted_categories[:
|
| 190 |
-
smallest_categories = sorted_categories_sm[:num_categories_to_display]
|
| 191 |
|
| 192 |
# Filter the dataframe to include only the largest categories
|
| 193 |
filtered_df = df[df['Category'].isin(largest_categories)]
|
| 194 |
-
filtered_cloud_df = df[df['Category'].isin(smallest_categories)]
|
| 195 |
|
| 196 |
# Sort the dataframe by Category
|
| 197 |
filtered_df = filtered_df.sort_values(by='Category')
|
| 198 |
-
filtered_cloud_df = filtered_cloud_df.sort_values(by='Category')
|
| 199 |
|
| 200 |
-
wordcloud_img = generate_wordcloud(
|
| 201 |
-
bar_chart_img = generate_bar_chart(
|
| 202 |
|
| 203 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".csv") as tmpfile:
|
| 204 |
filtered_df.to_csv(tmpfile.name, index=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 205 |
print(f"Error: {e}")
|
| 206 |
return str(e), None, None
|
| 207 |
|
| 208 |
-
|
| 209 |
interface = gr.Interface(
|
| 210 |
fn=main,
|
| 211 |
inputs=[
|
|
@@ -222,4 +211,3 @@ interface = gr.Interface(
|
|
| 222 |
)
|
| 223 |
|
| 224 |
interface.launch(share=True)
|
| 225 |
-
|
|
|
|
| 11 |
from PIL import Image
|
| 12 |
|
| 13 |
categories_keywords = {
|
| 14 |
+
'Application Status': ['application', 'applied', 'update on my application', 'result of my application', 'selected', 'selection process', 'apply', 'fellow', 'lesson plan', 'status of my application', 'application update', 'application status', 'applied for'],
|
| 15 |
+
'Volunteering': ['volunteering', 'volunteer', 'volunteering certificate', 'resume my volunteering', 'volunteering journey', 'volunteering with TFI', 'volunteering opportunities', 'volunteer work', 'volunteer program'],
|
| 16 |
+
'Certificates': ['certificate', 'certificates', 'certificate of completion', 'volunteer certificate', 'issue certificate'],
|
| 17 |
+
'Job Opportunities': ['job', 'vacancy', 'Talent Acquisition Executive job', 'opportunity', 'job opening', 'job position', 'career opportunities'],
|
| 18 |
+
'Surveys and Forms': ['survey', 'form', 'fill out the survey', 'application form', 'survey link', 'survey form', 'form submission'],
|
| 19 |
+
'General Queries': ['query', 'queries', 'questions', 'feedback', 'loved', 'overwhelming', 'general question', 'inquiry', 'query about'],
|
| 20 |
+
'Spam': ['free recharge', 'offer', 'click the link', 'https'],
|
| 21 |
+
'Rescheduling and Postponing': ['reschedule', 'postpone', 'cancellation', 'date', 'time slot', 'change date', 'change time', 'reschedule appointment'],
|
| 22 |
+
'Contact and Communication Issues': ['call', 'phone', 'contact', 'not received', 'contact support', 'phone call', 'call back', 'internet'],
|
| 23 |
+
'Email and Credentials Issues': ['email', 'credentials', 'received', 'email issue', 'email problem', 'credential issue', 'login problem'],
|
| 24 |
+
'Timing and Scheduling': ['session', 'time', 'interview', 'baje', 'schedule time', 'meeting time', 'appointment time'],
|
| 25 |
+
'Salary and Benefits': ['salary', 'increment', 'accommodation', 'training period', 'reside', 'stipend', 'pay', 'wage', 'salary details', 'benefits information'],
|
| 26 |
+
'Technical Issues': ['network issues', 'zoom meeting', 'passcode', 'technical', 'issue','technical problem', 'system issue', 'technical support'],
|
| 27 |
+
'Complaint Handling': ['help', 'i need help', 'Help me', 'complaint', 'issue is unresolved', 'unsatisfied', 'bad experience'],
|
| 28 |
+
'End of Conversation': ['thanks', 'thankss', 'thank u', 'thank you', 'ok', 'okay', 'done', 'joining', 'sounds good', 'goodbye', 'end chat', 'end'],
|
| 29 |
+
'Miscellaneous': []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
}
|
| 31 |
|
| 32 |
|
|
|
|
| 160 |
img = Image.open(buf)
|
| 161 |
return img
|
| 162 |
|
| 163 |
+
def main(file, num_clusters_to_display):
|
| 164 |
try:
|
| 165 |
df = pd.read_csv(file)
|
| 166 |
|
| 167 |
+
# Filter by 'Fallback Message shown'
|
| 168 |
+
df = df[df['Answer'] == 'Fallback Message shown']
|
| 169 |
|
| 170 |
df = preprocess_data(df)
|
|
|
|
|
|
|
| 171 |
|
| 172 |
+
# Get category sizes and sort by size in ascending order
|
| 173 |
category_sizes = df['Category'].value_counts().reset_index()
|
| 174 |
category_sizes.columns = ['Category', 'Count']
|
| 175 |
+
sorted_categories = category_sizes.sort_values(by='Count', ascending=True)['Category'].tolist()
|
|
|
|
|
|
|
| 176 |
|
| 177 |
+
# Get the largest x categories as specified by num_clusters_to_display
|
| 178 |
+
largest_categories = sorted_categories[:num_clusters_to_display]
|
|
|
|
| 179 |
|
| 180 |
# Filter the dataframe to include only the largest categories
|
| 181 |
filtered_df = df[df['Category'].isin(largest_categories)]
|
|
|
|
| 182 |
|
| 183 |
# Sort the dataframe by Category
|
| 184 |
filtered_df = filtered_df.sort_values(by='Category')
|
|
|
|
| 185 |
|
| 186 |
+
wordcloud_img = generate_wordcloud(filtered_df)
|
| 187 |
+
bar_chart_img = generate_bar_chart(filtered_df, num_clusters_to_display)
|
| 188 |
|
| 189 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".csv") as tmpfile:
|
| 190 |
filtered_df.to_csv(tmpfile.name, index=False)
|
| 191 |
+
csv_file_path = tmpfile.name
|
| 192 |
+
|
| 193 |
+
return csv_file_path, wordcloud_img, bar_chart_img
|
| 194 |
+
except Exception as e:
|
| 195 |
print(f"Error: {e}")
|
| 196 |
return str(e), None, None
|
| 197 |
|
|
|
|
| 198 |
interface = gr.Interface(
|
| 199 |
fn=main,
|
| 200 |
inputs=[
|
|
|
|
| 211 |
)
|
| 212 |
|
| 213 |
interface.launch(share=True)
|
|
|