Download tests/test_analyzer.py from no-singo/web: direct link, hf CLI and curl.
- Browser
- Download file 1.72 kB
-
https://huggingface.co/spaces/no-singo/web/resolve/main/tests/test_analyzer.py
- Command line
-
hf download hf://spaces/no-singo/web/tests/test_analyzer.py
-
curl -L -o test_analyzer.py https://huggingface.co/spaces/no-singo/web/resolve/main/tests/test_analyzer.py
1.72 kB
| import pytest | |
| from analyzer import analyze | |
| def test_ok(text): | |
| r = analyze(text) | |
| assert r["state"] == "ok", (text, r.get("realPos"), r.get("whList"), r.get("morphs")) | |
| def test_bad(text, fixed): | |
| r = analyze(text) | |
| assert r["state"] == "bad", (text, r.get("realPos"), r.get("whList"), r.get("morphs")) | |
| assert r["fixed"] == fixed, (text, r["fixed"]) | |
| def test_na(text): | |
| assert analyze(text)["state"] == "na" | |
| def test_empty(): | |
| assert analyze("")["state"] == "empty" | |
| assert analyze("ㅋㅋㅋ??")["state"] == "empty" | |
| def test_wh_highlight_offsets(): | |
| r = analyze("느그 아버지 뭐하시노?") | |
| assert r["hasWh"] | |
| (w,) = r["whList"] | |
| # 원문에서 해당 span이 실제 의문사 어절을 가리켜야 한다 | |
| assert "뭐" in r["stripped"][w["start"]:w["end"]] | |
| def test_dialect_wh_normalization(): | |
| # '어데'(=어디), '와'(=왜) 방언형도 의문사로 인식 | |
| assert analyze("어데 가노?")["hasWh"] | |
| assert analyze("와 이라노?")["hasWh"] | |