INNER CODE UNIT · Python

swap_z

OpenChemistry/avogadrolibs · scripts/copy-default.py:209

def swap_z(match):
    """Replace only the z with s (keeping case); the rest is kept as written."""
    stem, z, suffix = match.group(1), match.group(2), match.group(3)
    keep = match.group(0)[:len(stem) + 1]
    return keep + ('S' if z == 'Z' else 's') + suffix


def respell_text(text, locale):
    """Respell a run of plain text (no markup) for the locale."""
    text = WORD_RE.sub(common_word, text)
    if locale in ISE_LOCALES:
        text = ISE_RE.sub(swap_z, text)
        text = YSE_RE.sub(swap_z, text)
    return text


def respell(text, locale):
    """Respell text for the locale, leaving markup and URLs untouched."""

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…