Spaces:
Sleeping
Sleeping
Format precautions output as bullet points and normalize occurrences output
Browse files- frontend/app.py +14 -20
frontend/app.py
CHANGED
@@ -197,37 +197,31 @@ else:
|
|
197 |
|
198 |
# --- Functions for Symptom Detection ---
|
199 |
def precaution(label):
|
200 |
-
dataset_precau = pd.read_csv("disease_precaution.csv", encoding='latin1')
|
201 |
-
label = str(label)
|
202 |
-
|
203 |
-
|
204 |
dataset_precau["Disease"] = dataset_precau["Disease"].str.lower()
|
205 |
-
# Filter the DataFrame for the given label
|
206 |
filtered_precautions = dataset_precau[dataset_precau["Disease"] == label]
|
207 |
-
|
208 |
-
# Check if any precautions were found
|
209 |
if not filtered_precautions.empty:
|
210 |
-
# Extract precaution columns
|
211 |
precautions = filtered_precautions[["Precaution_1", "Precaution_2", "Precaution_3", "Precaution_4"]]
|
212 |
-
|
|
|
213 |
else:
|
214 |
-
return
|
215 |
|
216 |
def occurance(label):
|
217 |
dataset_occur = pd.read_csv("disease_riskFactors.csv", encoding='latin1')
|
218 |
-
label = str(label)
|
219 |
-
|
220 |
-
|
221 |
dataset_occur["DNAME"] = dataset_occur["DNAME"].str.lower()
|
222 |
-
# Filter the DataFrame for the given label
|
223 |
filtered_occurrence = dataset_occur[dataset_occur["DNAME"] == label]
|
224 |
-
|
225 |
-
|
226 |
-
if
|
227 |
-
|
228 |
-
return occurrences
|
229 |
else:
|
230 |
-
return
|
231 |
|
232 |
if page == "Home":
|
233 |
st.markdown("## Welcome to Medi Scape")
|
|
|
197 |
|
198 |
# --- Functions for Symptom Detection ---
|
199 |
def precaution(label):
|
200 |
+
dataset_precau = pd.read_csv("disease_precaution.csv", encoding='latin1') # Make sure this file is in the same directory
|
201 |
+
label = str(label).lower()
|
202 |
+
|
|
|
203 |
dataset_precau["Disease"] = dataset_precau["Disease"].str.lower()
|
|
|
204 |
filtered_precautions = dataset_precau[dataset_precau["Disease"] == label]
|
205 |
+
|
|
|
206 |
if not filtered_precautions.empty:
|
|
|
207 |
precautions = filtered_precautions[["Precaution_1", "Precaution_2", "Precaution_3", "Precaution_4"]]
|
208 |
+
precautions_list = precautions.values.flatten().tolist() # Flatten the DataFrame to a list of strings
|
209 |
+
return "\n".join(f"- {precaution}" for precaution in precautions_list) # Join the list into a single string with bullet points
|
210 |
else:
|
211 |
+
return "No precautions found."
|
212 |
|
213 |
def occurance(label):
|
214 |
dataset_occur = pd.read_csv("disease_riskFactors.csv", encoding='latin1')
|
215 |
+
label = str(label).lower()
|
216 |
+
|
|
|
217 |
dataset_occur["DNAME"] = dataset_occur["DNAME"].str.lower()
|
|
|
218 |
filtered_occurrence = dataset_occur[dataset_occur["DNAME"] == label]
|
219 |
+
|
220 |
+
occurrences = filtered_occurrence["OCCUR"].tolist() # Convert Series to list
|
221 |
+
if occurrences:
|
222 |
+
return "\n".join(occurrences) # Join the list into a single string with newlines
|
|
|
223 |
else:
|
224 |
+
return "No occurrences found."
|
225 |
|
226 |
if page == "Home":
|
227 |
st.markdown("## Welcome to Medi Scape")
|