Spaces:
Sleeping
Sleeping
File size: 1,399 Bytes
18bfaa1 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | 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()
|