tanish78 commited on
Commit
c1344f9
·
verified ·
1 Parent(s): 7b5aba0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -6
app.py CHANGED
@@ -29,18 +29,21 @@ categories_keywords = {
29
  'Miscellaneous': []
30
  }
31
 
 
32
  def categorize_question(question):
33
-
34
- for keyword in categories_keywords['End of Conversation']:
35
- if keyword.lower() in question.lower():
36
- return 'End of Conversation'
37
  for category, keywords in categories_keywords.items():
38
  for keyword in keywords:
39
  if keyword.lower() in question.lower():
40
- return category
 
 
 
 
 
41
  return 'Miscellaneous'
42
 
43
 
 
44
  def preprocess_data(df):
45
  df.rename(columns={'Question Asked': 'texts'}, inplace=True)
46
  df['texts'] = df['texts'].astype(str).str.lower()
@@ -207,4 +210,5 @@ interface = gr.Interface(
207
  description="Categorize unanswered user queries into predefined categories"
208
  )
209
 
210
- interface.launch(share=True)
 
 
29
  'Miscellaneous': []
30
  }
31
 
32
+
33
  def categorize_question(question):
 
 
 
 
34
  for category, keywords in categories_keywords.items():
35
  for keyword in keywords:
36
  if keyword.lower() in question.lower():
37
+ # Check if the question is one word and belongs to 'End of Conversation'
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
+
47
  def preprocess_data(df):
48
  df.rename(columns={'Question Asked': 'texts'}, inplace=True)
49
  df['texts'] = df['texts'].astype(str).str.lower()
 
210
  description="Categorize unanswered user queries into predefined categories"
211
  )
212
 
213
+ interface.launch(share=True)
214
+