tanish78 commited on
Commit
de1281a
·
verified ·
1 Parent(s): 2b9db4b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -9
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
- if keyword.lower() in question.lower():
47
- # Check if the question is one word and belongs to 'End of Conversation'
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