Spaces:
Running
Running
Update app.py
Browse files
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"]
|
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 |
-
|
43 |
-
|
44 |
-
|
|
|
|
|
|
|
|
|
|
|
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}")
|