Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -42,16 +42,26 @@ categories_keywords = {
|
|
| 42 |
|
| 43 |
def categorize_question(question):
|
| 44 |
words = question.split()
|
| 45 |
-
|
|
|
|
|
|
|
|
|
|
| 46 |
single_word = words[0].lower()
|
|
|
|
| 47 |
if any(single_word in keyword for keyword in categories_keywords["Start of Conversation"]):
|
| 48 |
return "Start of Conversation"
|
| 49 |
else:
|
| 50 |
return "End of Conversation"
|
| 51 |
|
|
|
|
| 52 |
for category, keywords in categories_keywords.items():
|
| 53 |
if any(keyword.lower() in question.lower() for keyword in keywords):
|
| 54 |
return category
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
return "Miscellaneous"
|
| 56 |
|
| 57 |
|
|
|
|
| 42 |
|
| 43 |
def categorize_question(question):
|
| 44 |
words = question.split()
|
| 45 |
+
|
| 46 |
+
exclusion_words = {'is', 'please', 'not', 'resolved', 'problem', 'help', 'issue', 'webinar', 'office', 'leave', 'approved', 'notice', 'period'}
|
| 47 |
+
|
| 48 |
+
if len(words) == 1:
|
| 49 |
single_word = words[0].lower()
|
| 50 |
+
# Check if the single word is in the Start of Conversation category
|
| 51 |
if any(single_word in keyword for keyword in categories_keywords["Start of Conversation"]):
|
| 52 |
return "Start of Conversation"
|
| 53 |
else:
|
| 54 |
return "End of Conversation"
|
| 55 |
|
| 56 |
+
# Categorization of other queries
|
| 57 |
for category, keywords in categories_keywords.items():
|
| 58 |
if any(keyword.lower() in question.lower() for keyword in keywords):
|
| 59 |
return category
|
| 60 |
+
|
| 61 |
+
# Secondary check for 'End of Conversation' category
|
| 62 |
+
if "End of Conversation" in question.lower() and not any(exclusion_word in question.lower() for exclusion_word in exclusion_words):
|
| 63 |
+
return "End of Conversation"
|
| 64 |
+
|
| 65 |
return "Miscellaneous"
|
| 66 |
|
| 67 |
|