Skip to main content

thalovant-languages

Every word a Thalovant component's rule turns on, for every language the sources know, derived from those sources and kept in one place, out of every codebase.

A voice satellite waits on "turn off the" because "the" is a continuation word. An intent listing closes "quelle heure est-il" with a question mark because "quelle" opens a question, and reads "volume {level} percent" aloud as "volume cinquante pour cent" in French. A French synthesiser is told to say "onze minutes" where it would swallow a consonant. Each of those is a fact about a language, not about the program that needs it. Here they are data: one directory per language, 270 of them, read by the SDK and by the satellite, and none of it written by hand.

Where the words come from

What Source How
continuation_words, trailing_words Universal Dependencies treebanks (150 languages) a word that is a determiner, preposition, conjunction, auxiliary or possessive nearly every time it appears, and almost never the last word of a sentence
question_openers Universal Dependencies an interrogative word (PronType=Int), or a word a sentence usually is a question when it starts with it
question_words_anywhere Universal Dependencies an interrogative word a sentence almost always is a question when it holds it, wherever it sits
written_forms Universal Dependencies a closed-class word written capitalised mid-sentence nine times in ten (i: I)
plural Unicode CLDR (190 locales) the language's plural rules, verbatim, evaluated at runtime by _plural.py
lowercase_map Unicode SpecialCasing.txt a language's own unconditional lower-case mappings: Turkish and Azeri's dotted and dotless i
scripts.yaml Unicode PropList.txt, Scripts.txt scripts written without spaces, scripts where a character is a syllable, the marks that close a sentence (Sentence_Terminal) or break a clause (Terminal_Punctuation), spaced or unspaced
slot_examples, speech_substitutions, question_patterns overrides/<tag>.yaml what only a person knows: how a slot reads aloud in a house, what a Piper voice mispronounces, an inversion no treebank lists

Every generated file starts with a header naming its sources, their versions, the treebanks it was read from, and the thresholds that decided what got in. The thresholds are numbers a reader can argue with; the argument then has its facts. Two of them were settled by measurement on the voice satellite: English "is" ends three sentences in a hundred and is worth waiting on, "on" ends six ("turn it on") and is not.

Layout

src/thalovant_languages/languages/
  scripts.yaml            what a writing system does that no word list can
  en/language.yaml        English, every region
  fr/language.yaml        French
  pt/language.yaml        Portuguese ...
  pt-PT/language.yaml     ... and what European Portuguese does differently
overrides/
  en.yaml, fr.yaml        what only a person knows, laid on top
  scripts.yaml            the two marks the synthesiser splits on that Unicode does not list
scripts/derive.py         the generator

A directory is named by a BCP-47 tag: bare when what it says holds for every region, regional when a source says the region differs (CLDR gives pt-PT its own plural rule). A regional file carries only the difference; the loader lays it over the language's file.

Use

import thalovant_languages as languages

languages.language("fr-CA")["continuation_words"]   # the French file
languages.words("en", "trailing_words")             # lower-cased, as a set
languages.plural_category("ru", 21)                 # "one", by CLDR's rules
languages.language("tlh")                           # {} -- nothing describes it
languages.script_pattern("unspaced").search("今天") # a character of an unspaced script
languages.marks("sentence_ends", "spaced")          # every Sentence_Terminal mark, and "…;"

A language is found by the matcher the rest of OVOS uses (ovos_spec_tools.language): fr-CA reads fr, en-GB reads en, and a language nothing describes gets an empty mapping rather than another language's rules. The keys a component reads are thalovant_languages.KEYS.

THALOVANT_LANGUAGES_DIR=/path/to/checkout/src/thalovant_languages/languages reads a checkout instead of the installed data, for trying a change before it is released; languages.refresh() forgets what was read after changing it.

Regenerating

pip install -e ".[dev]"
curl -LO https://www.unicode.org/Public/UCD/latest/ucd/PropList.txt      # and Scripts.txt, SpecialCasing.txt
curl -LO https://raw.githubusercontent.com/unicode-org/cldr-json/main/cldr-json/cldr-core/supplemental/plurals.json
# the treebanks: https://universaldependencies.org/ -> the current release archive (~700 MB)
python scripts/derive.py --ud ud-treebanks-v2.18 --cldr plurals.json --unicode .
thalovant-languages check
git diff --stat

The generator reads about four gigabytes of treebanks in a minute or two and rewrites every file; review the diff, commit. To change a word, do not edit the file: change the generator's thresholds, or put what you know in overrides/, and rerun. thalovant-languages check refuses a key no component reads, a pattern that does not compile, a plural rule the evaluator cannot read, and a list holding a boolean.

Who reads it

  • thalovant (the Python SDK): thalovant.listing sets a registered pattern the way a person reads it, ranks phrases, and reads slots aloud.
  • thalovant-voice (the satellite): the semantic endpoint's continuation words, the lower-casing of an all-capitals transcript, the plural forms of its own counted text, the synthesiser's pronunciation repairs.

Nothing here parses dates, numbers or colours; the OVOS parsers do that for skills on the hub. Contractions come from ovos-utterance-normalizer, which already carries them.

Metadata

Release files for thalovant-languages 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for thalovant-languages 0.2.0
File Size Uploaded
thalovant_languages-0.2.0.tar.gz 57.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for thalovant-languages 0.2.0
File Interpreter ABI Platform
thalovant_languages-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 275.5 kB

Release files / thalovant_languages-0.2.0.tar.gz

Download URL thalovant_languages-0.2.0.tar.gz
Size 57.1 kB
Tags Source
SHA-256 checksum
How to use checksums
7d1b98f649b004127f3a558bb2bc9184c48df4ef65d2fd69154c306ac65a9fa0
BLAKE2b-256 checksum
How to use checksums
0f12cf2140f2571ea8ee42073a5e6fb67cbd962114f9557f2ceee7713bbeb68c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / thalovant_languages-0.2.0-py3-none-any.whl

Download URL thalovant_languages-0.2.0-py3-none-any.whl
Size 218.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
092114d19f8b8869d339401685dc44612729f03783d9da2e85117375bb7d8ef2
BLAKE2b-256 checksum
How to use checksums
ca02a9e0dbf67d8081874d6c3bdf32ffd1e7233887934988372ab06bcce46ad1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.1

2 release files

This release

0.2.0 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page