Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,36 +11,50 @@ 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 |
}
|
| 31 |
|
| 32 |
-
|
| 33 |
def categorize_question(question):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
for category, keywords in categories_keywords.items():
|
| 35 |
-
for keyword in keywords:
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
if category == 'End of Conversation':
|
| 39 |
-
return category
|
| 40 |
-
# If not 'End of Conversation', return the matched category
|
| 41 |
-
if category != 'End of Conversation':
|
| 42 |
-
return category
|
| 43 |
-
return 'Miscellaneous'
|
| 44 |
|
| 45 |
|
| 46 |
|
|
|
|
| 11 |
from PIL import Image
|
| 12 |
|
| 13 |
categories_keywords = {
|
| 14 |
+
"Application Status": ["application status", "application", "status", "submitted", "processing", "pending", "approval", "rejected", "accepted"],
|
| 15 |
+
"Volunteering": ["volunteer", "volunteering", "help out", "assist", "volunteer work", "volunteer opportunities"],
|
| 16 |
+
"Certificates": ["certificate", "certificates", "completion", "certification", "accreditation", "proof", "document", "certified"],
|
| 17 |
+
"Job Opportunities": ["job", "opportunity", "career", "vacancy", "position", "employment", "hiring", "recruitment", "internship"],
|
| 18 |
+
"Surveys and Forms": ["survey", "form", "forms", "questionnaire", "feedback form", "response", "fill out", "submission"],
|
| 19 |
+
"General Queries": ["hello", "hi", "help", "general", "query", "question", "info", "information", "inquiry", "ask"],
|
| 20 |
+
"Spam": ["spam", "unsubscribe", "remove", "stop", "junk", "block", "opt-out"],
|
| 21 |
+
"Rescheduling and Postponing": ["reschedule", "postpone", "delay", "change date", "new time", "rearrange", "shift", "adjust timing"],
|
| 22 |
+
"Contact and Communication Issues": ["contact", "communicate", "communication", "reach out", "phone", "email", "address", "details"],
|
| 23 |
+
"Email and Credentials Issues": ["email", "credentials", "login", "password", "access", "username", "account", "verification", "reset"],
|
| 24 |
+
"Timing and Scheduling": ["timing", "schedule", "scheduling", "time", "appointment", "availability", "calendar", "book", "slot"],
|
| 25 |
+
"Salary and Benefits": ["salary", "benefits", "pay", "compensation", "wages", "earnings", "package", "remuneration", "incentives"],
|
| 26 |
+
"Technical Issues": ["technical", "issue", "problem", "error", "bug", "glitch", "fix", "troubleshoot", "support"],
|
| 27 |
+
"End of Conversation": ["bye", "thank you", "thanks", "goodbye", "see you", "later", "end", "close", "sign off"],
|
| 28 |
+
"Start of Conversation": ["start", "begin", "hello", "hi", "initiate", "greet", "greeting", "open", "commence"],
|
| 29 |
+
"Feedback": ["feedback", "comments", "review", "opinion", "suggestion", "critique", "rating"],
|
| 30 |
+
"Event Inquiries": ["event", "webinar", "meeting", "conference", "session", "seminar", "workshop", "invitation"],
|
| 31 |
+
"Payment Issues": ["payment", "billing", "transaction", "charge", "fee", "invoice", "refund", "receipt"],
|
| 32 |
+
"Registration Issues": ["registration", "register", "sign up", "enroll", "join", "signup", "enrollment"],
|
| 33 |
+
"Service Requests": ["service", "support", "request", "assistance", "help", "aid", "maintenance"],
|
| 34 |
+
"Account Issues": ["account", "profile", "update", "activation", "deactivation", "credentials", "reset"],
|
| 35 |
+
"Product Information": ["product", "service", "details", "info", "information", "specifications", "features"],
|
| 36 |
+
"Order Status": ["order", "status", "tracking", "shipment", "delivery", "purchase", "dispatch"],
|
| 37 |
+
"Miscellaneous": ["miscellaneous", "other", "various", "random", "general", "unknown", "unsorted"]
|
| 38 |
}
|
| 39 |
|
|
|
|
| 40 |
def categorize_question(question):
|
| 41 |
+
# Split the question into words
|
| 42 |
+
words = question.split()
|
| 43 |
+
|
| 44 |
+
# Check if the question has only one word
|
| 45 |
+
if len(words) == 1:
|
| 46 |
+
single_word = words[0].lower()
|
| 47 |
+
# Check if the single word is in the Start of Conversation category
|
| 48 |
+
if any(single_word in keyword for keyword in categories_keywords["Start of Conversation"]):
|
| 49 |
+
return "Start of Conversation"
|
| 50 |
+
else:
|
| 51 |
+
return "End of Conversation"
|
| 52 |
+
|
| 53 |
+
# Categorization of other queries
|
| 54 |
for category, keywords in categories_keywords.items():
|
| 55 |
+
if any(keyword.lower() in question.lower() for keyword in keywords):
|
| 56 |
+
return category
|
| 57 |
+
return "Miscellaneous"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
|
| 59 |
|
| 60 |
|