Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -41,16 +41,18 @@ categories_keywords = {
|
|
| 41 |
|
| 42 |
|
| 43 |
def categorize_question(question):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
for category, keywords in categories_keywords.items():
|
| 45 |
-
for keyword in keywords:
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
if category == 'End of Conversation':
|
| 49 |
-
return category
|
| 50 |
-
# If not 'End of Conversation', return the matched category
|
| 51 |
-
if category != 'End of Conversation':
|
| 52 |
-
return category
|
| 53 |
-
return 'Miscellaneous'
|
| 54 |
|
| 55 |
|
| 56 |
|
|
|
|
| 41 |
|
| 42 |
|
| 43 |
def categorize_question(question):
|
| 44 |
+
words = question.split()
|
| 45 |
+
if len(words) == 1:
|
| 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 |
|
| 58 |
|