Haseeb-001 commited on
Commit
7e8afef
·
verified ·
1 Parent(s): ba5df13

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -5
app.py CHANGED
@@ -36,12 +36,17 @@ index = faiss.IndexFlatL2(embedding_dim)
36
  # Function to Check Query Category
37
  def preprocess_query(query):
38
  tokens = query.lower().split()
39
- epilepsy_keywords = ["seizure", "epilepsy", "convulsion", "neurology", "brain activity", "headache related to epilepsy"] # Added specific phrase
40
- healthcare_keywords = ["headache", "fever", "blood pressure", "diabetes", "cough", "flu", "nutrition", "mental health", "pain", "legs", "body pain", "health", "medical", "symptoms", "treatment", "disease", "illness"] # Extended healthcare keywords - added "illness"
41
 
42
- is_epilepsy_related = any(k in tokens for k in epilepsy_keywords)
43
- is_healthcare_related = any(k in tokens for k in healthcare_keywords) and not is_epilepsy_related # Healthcare but NOT epilepsy
44
- is_general = not is_epilepsy_related and not is_healthcare_related # Truly general queries
 
 
 
 
 
45
 
46
  print(f"Query: {query}") # Debugging prints
47
  print(f"Tokens: {tokens}")
 
36
  # Function to Check Query Category
37
  def preprocess_query(query):
38
  tokens = query.lower().split()
39
+ epilepsy_keywords = ["seizure", "epilepsy", "convulsion", "neurology", "brain activity", "headache related to epilepsy"]
40
+ healthcare_keywords = ["headache", "fever", "blood pressure", "diabetes", "cough", "flu", "nutrition", "mental health", "pain", "legs", "body pain", "health", "medical", "symptoms", "treatment", "disease", "illness"]
41
 
42
+ is_healthcare_related = False # Initialize to False
43
+ for keyword in healthcare_keywords: # Explicitly check for healthcare keywords first
44
+ if keyword in tokens:
45
+ is_healthcare_related = True
46
+ break # Exit loop once a healthcare keyword is found
47
+
48
+ is_epilepsy_related = any(k in tokens for k in epilepsy_keywords) and not is_healthcare_related # Epilepsy check AFTER healthcare
49
+ is_general = not is_epilepsy_related and not is_healthcare_related
50
 
51
  print(f"Query: {query}") # Debugging prints
52
  print(f"Tokens: {tokens}")