INNER CODE UNIT · Python
respell
OpenChemistry/avogadrolibs · scripts/copy-default.py:225
def respell(text, locale):
"""Respell text for the locale, leaving markup and URLs untouched."""
if locale not in RESPELL_LOCALES or not text:
return text
pieces = MARKUP_RE.split(text)
for i in range(0, len(pieces), 2):
pieces[i] = respell_text(pieces[i], locale)
return ''.join(pieces)
PLURAL_S_RE = re.compile(r'([A-Za-z])\(s\)')
# Words that signal verb or pronoun agreement a script cannot fix
AGREEMENT_RE = re.compile(r'\b(have|are|were|do|these|them)\b', re.IGNORECASE)
def resolve_plural(text, singular):
"""Resolve "(s)" in the plain text of a plural entry's form."""