Repository navigation
Conversation
A join word such as Luganda "mu" ("in") is also an ordinary word. A run of
number words could start with one, so "kasa vo mina epi" had two equally best
readings: "vo" as a word followed by 20,000 XTS, or "vo mina epi" as one
malformed run left unchanged. The runtime picked one silently.
Runs now start with a number word that is not a join. Joins before the first
run with no ordinary word (or the whole input) are words. On 12,121 generated
inputs the output is unchanged; the one difference is that "koin ke mina
otodeka" now has one best reading instead of two (same text). An input that
starts with a join and then an amount now converts: "vo mina epi" ->
"vo 20,000 XTS" (was left unchanged).
Signed-off-by: Lwanga Caleb <[email protected]>
Adds Luganda as a NeMo ITN language built on the Bantu kernel: word lists in lg/data/*.tsv, grammar settings in lg/settings.py, and the standard ClassifyFst / VerbalizeFst / VerbalizeFinalFst wrappers. No changes to bantu/. The only Luganda-specific step splits contracted "and" off a plural scale word (n'emitwalo ebiri -> ne 20,000 UGX). The split is kept only where the kernel converts the amount after it; otherwise the words are left unchanged. Registered in InverseNormalizer, run_evaluate.py, pynini_export.py and the Jenkinsfile. Tests: 237 reviewed spoken/written pairs (cardinal, money, word), each with exactly one best reading; grammar tests for caching, cased input and the export verbalizer; a Sparrowhawk test script. Signed-off-by: Lwanga Caleb <[email protected]>
…dd tutorial notebook - Extend split_contracted_and to singular augmented scale words present in the Luganda word lists (omutwalo, akakadde, akawumbi), so n'omutwalo gumu and n'akakadde kamu normalize to money while bare forms stay unchanged. - Replace unnatural n' regression strings with native-speaker-reviewed Luganda test cases (233 pairs total: 130 cardinal, 89 money, 14 word). - Add the companion tutorial notebook tutorials/Luganda_ITN_on_the_Bantu_Kernel.ipynb. Signed-off-by: Lwanga Caleb <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do ?
Adds Luganda (
lg) inverse text normalization, built on the shared Bantu kernel from #518.Luganda is a normal NeMo ITN language: its word lists are in
lg/data/*.tsv, its grammarsettings are in
lg/settings.py, and the grammar is built by the kernel. The onlyLuganda-specific code is one small step that runs before the kernel (splitting the
contracted n', "and", off a scale word; see below). No changes to
bantu/.This is stage 2 of the plan agreed with @tbartley94: kernel (#518), then Luganda, then
Swahili. It also includes the companion tutorial notebook
(
tutorials/Luganda_ITN_on_the_Bantu_Kernel.ipynb) walking through Luganda on the kernel;happy to split it into a separate PR if you'd rather review it on its own.
Depends on #544 (a run of number words never starts with a join word). This branch is
built on it, so its one commit shows here until #544 merges; I'll rebase onto
staging/bantu_itnthen. Two of the test sentences need that fix.Collection: ITN
Examples
The first two rows are the reason the kernel exists: abiri is 2 after amagi (eggs) but
20 after a currency phrase. The word before a number decides its value.
Supported classes in this PR:
cardinal,money(UGX, KES, TZS, USD) and plain words.What Luganda supplies
lg/data/): number words per noun class, places (tens, hundreds,thousands, ten-thousands), the scale words mitwalo, bukadde and buwumbi with their
counts, currency phrases, money cues, and spelling variants. All reviewed by a native
speaker.
lg/settings.py): noun classes, kkumi (ten), the joins na and mu,the counted scales and their switches, the largest value (999,999,999,999). Each
reviewed decision is a comment next to the setting it controls.
ebiri) mean UGX. The longer forms (emitwalo ebiri) count the word before them
(embuzi emitwalo ebiri = 20,000 goats) unless a money word comes right before
(yampa, ssente, the payment verbs in
cues.tsv).lg/taggers/tokenize_and_classify.py): Luganda writes "and"before a vowel attached to the next word: n'emitwalo, n'omutwalo, n'akakadde.
Before the kernel reads the sentence, n' (or n) + an augmented scale word (derived
from the word lists) may be split into
ne+ the bare scale word. The split is kept onlywhere the kernel then converts the amount right after
ne(a filter on the classifier'soutput); anywhere else the original words stand. So yampa emmere n'emitwalo ebiri
becomes yampa emmere ne 20,000 UGX and n'omutwalo gumu becomes ne 10,000 UGX, while
n'omutwalo gwange, yampa emmere n'omutwalo and n'obukadde bubiri n'ekitundu (held
back) are left exactly as written. The step is part of the tagger FST, so the export and
Sparrowhawk get it unchanged. If another language needs it, it can move into the kernel
then.
Files
Tests
also checks that the input has exactly one best reading, as in
toy.nouns counted with a scale word (embuzi emitwalo ebiri = 20,000, no currency),
mu as "in" (omuti guli mu nnimiro), and n' + a scale word where no valid amount
follows (a possessive, a bare scale word, a held-back "and a half" phrase).
test_grammar.py: the FAR cache round trip, cased input, the split after repeatedspaces, the CLI choice and the export verbalizer.
lg/.bantuandtoytests unchanged andpassing.
test_sparrowhawk_inverse_text_normalization.shpassed on the exportedgrammars (cardinal, money, word), run locally in Docker on Linux x86_64;
pynini_export.pywas re-verified after expanding the n' split to singular scale words and replacing the
unnatural regression strings with speaker-reviewed pairs. The machine runs rootless Docker,
so two local changes were needed to build and start the container, neither touching the
grammars or the test:
tar --no-same-ownerwhen unpacking protobuf in the image, and no--ulimit memlock=-1. The script'sPROJECT_DIRdefaults to/workspace/tests(withhy's default,/workspace/tests/en, neither the case files nor shUnit2 are found whenrun through
export_grammars.sh --MODE=test).Test data
Every pair was written for this project and reviewed by a native Luganda speaker; none
comes from an ASR corpus or other training data. Sources used to check linguistic facts
(not copied): Kizito, Okello and Kagumire (2020) on Luganda text normalization, a 2017
Luganda grammar guide, and Ministry of Education P1 mathematics material.
Known limits
Each one has a test showing the current output.
ssente ziri 30,000(no UGX). The money word has to come right before the amount. Fixing this would be a
kernel change; we'd rather look at it with Swahili first.
unchanged (n'omutwalo gumu ->
ne 10,000 UGXand n'akakadde kamu ->ne 1,000,000 UGXconvert).
follow-up PR. Reviewed cases exist; they need new kernel code (a decimal tagger).
input_case='cased'builds the same grammar;words with capitals or attached punctuation pass through unchanged.
Questions for the reviewer
lgtests build the grammar in the test run (about a minute), likethe Bantu kernel stage, so there is no
LG_TN_CACHEpath. Would you like a cachedgrammar and an
L0stage instead? The path is yours to set.lg(ISO 639-1). The profile's internal name matches.Not in this PR
Before your PR is "Ready for review"
Pre checks:
git commit -sto sign.pytestor (if your machine does not have GPU)pytest --cpufrom the root folder (given you marked your test cases accordingly@pytest.mark.run_only_on('CPU')).bash tools/text_processing_deployment/export_grammars.sh --MODE=test ...pytestand Sparrowhawk here.__init__.pyfor every folder and subfolder, includingdatafolder which has .TSV files?Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.to all newly added Python files? (year 2026, with the Crane AI Labs line)Copyright 2015 and onwards Google, Inc.. n/a, imported, not copiedtry import: ... except: ...) if not already done. None presentPR Type:
If you haven't finished some of the above items you can still open "Draft" PR.