CoolFace
Apppublic

bnewcomer/MediBot

sourceHugging Facemitupdated 6mo agoView on Hugging Face
0likes
smoke_check.py53 linesDownload Raw Back to scripts
1from pathlib import Path2import sys3 4import pandas as pd5 6ROOT = Path(__file__).resolve().parents[1]7if str(ROOT) not in sys.path:8    sys.path.insert(0, str(ROOT))9 10from diagnosis_engine.vocabulary import map_to_known_symptoms  # noqa: E40211 12 13def load_all_symptoms() -> list[str]:14    df = pd.read_csv(ROOT / "data" / "dataset.csv")15    symptoms: set[str] = set()16    for col in [c for c in df.columns if c.lower().startswith("symptom")]:17        for value in df[col].dropna():18            text = str(value).strip().lower()19            if text:20                symptoms.add(text)21    return sorted(symptoms)22 23 24def assert_equal(actual, expected, label: str) -> None:25    if actual != expected:26        raise AssertionError(f"{label}: expected {expected}, got {actual}")27 28 29def main() -> None:30    all_symptoms = load_all_symptoms()31 32    assert_equal(33        map_to_known_symptoms(["shortness_of_breath"], all_symptoms),34        ["breathlessness"],35        "shortness_of_breath mapping",36    )37    assert_equal(38        map_to_known_symptoms(["chest_pain", "shortness_of_breath"], all_symptoms),39        ["chest_pain", "breathlessness"],40        "chest pain plus shortness of breath mapping",41    )42    assert_equal(43        map_to_known_symptoms(["rash"], all_symptoms),44        ["skin_rash"],45        "rash mapping",46    )47 48    print("Smoke checks passed.")49 50 51if __name__ == "__main__":52    main()53