INNER CODE UNIT · Python

KOREAN_RATIO_THRESHOLD

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

KOREAN_RATIO_THRESHOLD = 0.15  # Hangul / (Hangul + Latin) letters, whole-file basis


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

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…