From e05a75f9ef628aab88226e56a00a3f3da106231a Mon Sep 17 00:00:00 2001 From: Ronald Tse Date: Thu, 1 Oct 2026 19:37:06 +0800 Subject: [PATCH] fix: render the any_character function item MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit any_character parses as a function item, not an alias reference, and the item renderers had no branch for it — every rule guarded by before any_character + any_character was silently dropped. kp-kor's generic-suffix hyphenation (Kobi-ri) is built from such guards. Direct corpus sweep: 35 failures / 13 maps -> 16 / 10 — kp-kor (8), var-zho-wd (8) and odni-uzb (3) fully healed. --- src/interscript/isc.py | 4 ++++ tests/test_engine.py | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/interscript/isc.py b/src/interscript/isc.py index 6d3535b..12b2355 100644 --- a/src/interscript/isc.py +++ b/src/interscript/isc.py @@ -693,6 +693,8 @@ def _render_item(item: dict, aliases: dict[str, str]) -> str: if name == "line_end": return "line_end" raise UnsupportedConstruct(f"primitive {name}") + if kind == "function" and item["name"] == "any_character": + return "any_character" if kind == "alias_ref": name = item["name"] if item.get("map"): @@ -759,6 +761,8 @@ def _regex_of(item: dict, aliases: dict[str, str]) -> str: "line_end": "$", "space": " ", }.get(item["name"], None) or _unsupported_primitive(item["name"]) + if kind == "function" and item["name"] == "any_character": + return "." if kind == "alias_ref": name = item["name"] if item.get("map"): diff --git a/tests/test_engine.py b/tests/test_engine.py index 76041e5..2564cbb 100644 --- a/tests/test_engine.py +++ b/tests/test_engine.py @@ -346,3 +346,14 @@ def test_par_unsafe_rule_forces_megaregexp_first_wins(): ' }\n}\n' ) assert Engine(tree).transliterate("i") == "X" + + +@pytest.mark.skipif(not MAPS.is_dir(), reason="interscript maps repo not present") +def test_any_character_renders(): + """kp-kor hyphenates generics with before any_character + + any_character guards; the item renderer had no branch for the + any_character function item and silently dropped every such rule + (고비리 -> Kobiri instead of Kobi-ri).""" + e = _load("kp-kor-Hang-Latn-2002") + assert e.transliterate("고비리") == "Kobi-ri" + assert e.transliterate("교구동") == "Kyogu-dong"