Spaces:
Sleeping
Sleeping
Download scripts/smoke_check.py from bnewcomer/MediBot: direct link, hf CLI and curl.
- Browser
- Download file 1.4 kB
-
https://huggingface.co/spaces/bnewcomer/MediBot/resolve/main/scripts/smoke_check.py
- Command line
-
hf download hf://spaces/bnewcomer/MediBot/scripts/smoke_check.py
-
curl -L -o smoke_check.py https://huggingface.co/spaces/bnewcomer/MediBot/resolve/main/scripts/smoke_check.py
1.4 kB
| from pathlib import Path | |
| import sys | |
| import pandas as pd | |
| ROOT = Path(__file__).resolve().parents[1] | |
| if str(ROOT) not in sys.path: | |
| sys.path.insert(0, str(ROOT)) | |
| from diagnosis_engine.vocabulary import map_to_known_symptoms # noqa: E402 | |
| def load_all_symptoms() -> list[str]: | |
| df = pd.read_csv(ROOT / "data" / "dataset.csv") | |
| symptoms: set[str] = set() | |
| for col in [c for c in df.columns if c.lower().startswith("symptom")]: | |
| for value in df[col].dropna(): | |
| text = str(value).strip().lower() | |
| if text: | |
| symptoms.add(text) | |
| return sorted(symptoms) | |
| def assert_equal(actual, expected, label: str) -> None: | |
| if actual != expected: | |
| raise AssertionError(f"{label}: expected {expected}, got {actual}") | |
| def main() -> None: | |
| all_symptoms = load_all_symptoms() | |
| assert_equal( | |
| map_to_known_symptoms(["shortness_of_breath"], all_symptoms), | |
| ["breathlessness"], | |
| "shortness_of_breath mapping", | |
| ) | |
| assert_equal( | |
| map_to_known_symptoms(["chest_pain", "shortness_of_breath"], all_symptoms), | |
| ["chest_pain", "breathlessness"], | |
| "chest pain plus shortness of breath mapping", | |
| ) | |
| assert_equal( | |
| map_to_known_symptoms(["rash"], all_symptoms), | |
| ["skin_rash"], | |
| "rash mapping", | |
| ) | |
| print("Smoke checks passed.") | |
| if __name__ == "__main__": | |
| main() | |