INNER CODE UNIT · Python

_hangul_ratio

sangrokjung/claude-forge · scripts/emdash_slop_check.py:60

def _hangul_ratio(text: str) -> float:
    """Hangul share of the letters in `text`; 0.0 when there are no letters."""
    hangul = len(HANGUL_PATTERN.findall(text))
    latin = len(LATIN_PATTERN.findall(text))
    total = hangul + latin
    if total == 0:
        return 0.0
    return hangul / total


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).
    """

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…