Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -45,21 +45,25 @@ def categorize_question(question):
|
|
| 45 |
|
| 46 |
# List of words to exclude from 'End of Conversation'
|
| 47 |
exclusion_words = {'is', 'please', 'not', 'resolved', 'problem', 'help', 'issue', 'webinar', 'office', 'leave', 'approved', 'notice', 'period'}
|
| 48 |
-
|
| 49 |
# Check if the question has only one word
|
| 50 |
if len(words) == 1:
|
| 51 |
single_word = words[0].lower()
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
|
|
|
|
|
|
| 56 |
return "End of Conversation"
|
| 57 |
-
|
|
|
|
|
|
|
| 58 |
# Categorization of other queries
|
| 59 |
for category, keywords in categories_keywords.items():
|
| 60 |
if any(keyword.lower() in question.lower() for keyword in keywords):
|
| 61 |
return category
|
| 62 |
-
|
| 63 |
# Secondary check for 'End of Conversation' category
|
| 64 |
if "end of conversation" in question.lower() and not any(exclusion_word in question.lower() for exclusion_word in exclusion_words):
|
| 65 |
return "End of Conversation"
|
|
@@ -67,7 +71,6 @@ def categorize_question(question):
|
|
| 67 |
return "Miscellaneous"
|
| 68 |
|
| 69 |
|
| 70 |
-
|
| 71 |
def preprocess_data(df):
|
| 72 |
df.rename(columns={'Question Asked': 'texts'}, inplace=True)
|
| 73 |
df['texts'] = df['texts'].astype(str).str.lower()
|
|
|
|
| 45 |
|
| 46 |
# List of words to exclude from 'End of Conversation'
|
| 47 |
exclusion_words = {'is', 'please', 'not', 'resolved', 'problem', 'help', 'issue', 'webinar', 'office', 'leave', 'approved', 'notice', 'period'}
|
| 48 |
+
|
| 49 |
# Check if the question has only one word
|
| 50 |
if len(words) == 1:
|
| 51 |
single_word = words[0].lower()
|
| 52 |
+
# Check if the single word fits into any other category
|
| 53 |
+
for category, keywords in categories_keywords.items():
|
| 54 |
+
if any(single_word in keyword for keyword in keywords):
|
| 55 |
+
return category
|
| 56 |
+
# If it doesn't fit into any other category, check if it should be 'End of Conversation'
|
| 57 |
+
if any(single_word in keyword for keyword in categories_keywords["End of Conversation"]):
|
| 58 |
return "End of Conversation"
|
| 59 |
+
else:
|
| 60 |
+
return "Miscellaneous"
|
| 61 |
+
|
| 62 |
# Categorization of other queries
|
| 63 |
for category, keywords in categories_keywords.items():
|
| 64 |
if any(keyword.lower() in question.lower() for keyword in keywords):
|
| 65 |
return category
|
| 66 |
+
|
| 67 |
# Secondary check for 'End of Conversation' category
|
| 68 |
if "end of conversation" in question.lower() and not any(exclusion_word in question.lower() for exclusion_word in exclusion_words):
|
| 69 |
return "End of Conversation"
|
|
|
|
| 71 |
return "Miscellaneous"
|
| 72 |
|
| 73 |
|
|
|
|
| 74 |
def preprocess_data(df):
|
| 75 |
df.rename(columns={'Question Asked': 'texts'}, inplace=True)
|
| 76 |
df['texts'] = df['texts'].astype(str).str.lower()
|