INNER CODE UNIT · Python
is_korean_dominant
sangrokjung/claude-forge · scripts/emdash_slop_check.py:70
def is_korean_dominant(text: str, threshold: float = KOREAN_RATIO_THRESHOLD) -> bool:
"""True if the file's letters are mostly Hangul rather than Latin.
Deliberate tradeoff: this is a whole-file ratio. A mostly-English doc with
one Korean paragraph containing a real em-dash violation will not be
flagged — that's the accepted cost of not firing on English docs at all
(the false-positive class this checker exists to eliminate).
"""
return _hangul_ratio(text) >= threshold
def is_korean_line(line: str, threshold: float = KOREAN_RATIO_THRESHOLD) -> bool:
"""True if this single line reads as Korean rather than English.
Runs after the whole-file gate, on the line about to be recorded. Korean
documents quote English, and an em-dash aside inside an English sentence
is correct English prose — flagging it is noise regardless of what
language the rest of the file is in.