tetrak_translit.fold

tetrak_translit.fold(text, *, script=None, scheme=None)[source]

Fold text onto its canonical index form.

Parameters:
  • text (str) – Text in a registered script, Latin in any of its romanisations, or a mixture. Tokens are folded one at a time and joined with single spaces.

  • script (str | Script | None) – Which script’s rules Latin tokens get: a key ("hy", "ka") or name. Tokens written in a registered script are recognised regardless. Required if any token is Latin.

  • scheme (str | Scheme | None) – Optional. When the Latin in text is known to be written in a reversible scheme ("iso_9985", "hubschmann_meillet", "ka/iso_9984"), name it and the text is read back into the script exactly before folding, which removes the ambiguities the heuristic fold has (Armenian j). For a lossy scheme the heuristic fold is used. Either way the scheme’s script becomes the default for Latin tokens.

Returns:

for comparing and indexing, never for display.

Return type:

A lowercase ASCII key

Raises:
  • ScriptRequiredError – a Latin token and no script.

  • UnknownScriptError, UnknownSchemeError – the names resolve to nothing.