!pip install -q condacolab
import condacolab
condacolab.install()
⏬ Downloading https://github.com/jaimergp/miniforge/releases/latest/download/Mambaforge-colab-Linux-x86_64.sh...
📦 Installing...
📌 Adjusting configuration...
🩹 Patching environment...
⏲ Done in 0:00:39
🔁 Restarting kernel...
%%capture
!conda install -c conda-forge pynini
%%capture
!pip install pyicu
import pynini
import icu
formatter = icu.RuleBasedNumberFormat(icu.URBNFRuleSetTag.SPELLOUT, icu.Locale('ga'))
for i in range(0, 10):
  print(formatter.format(i))
a náid
a haon
a dó
a trí
a ceathair
a cúig
a sé
a seacht
a hocht
a naoi
pynini.cross("0", "a náid") | pynini.cross("1", "a haon")
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> FST 15 15 0 0 15->0 0:0 8 8 15->8 0:0 1 1 0->1 48:97 9 9 8->9 49:97 2 2 1->2 0:32 3 3 2->3 0:110 4 4 3->4 0:195 5 5 4->5 0:161 6 6 5->6 0:105 7 7 6->7 0:100 10 10 9->10 0:32 11 11 10->11 0:104 12 12 11->12 0:97 13 13 12->13 0:111 14 14 13->14 0:110
i = 1
print(f"{i:03d}")
001
count_1_999 = pynini.union(*[pynini.cross(f"{i:03d}", formatter.format(i)) for i in range(1, 1000)])
count_1_999_x1000 = pynini.union(*[pynini.cross(f"{i:03d}", formatter.format(i * 1000)) for i in range(1, 1000)])
("999" @ count_1_999_x1000).string()
'naoi gcéad nócha is naoi míle'
count_1_999_x1000000 = pynini.union(*[pynini.cross(f"{i:03d}", formatter.format(i * 1000000)) for i in range(1, 1000)])
drop_000 = pynini.cross("000", "")
ins_space = pynini.cross("", " ")
ins_space_or_is = (pynini.cross("", " ") | pynini.cross("", " is "))
("999" @ count_1_999_x1000000).string()
'naoi gcéad nócha is naoi milliún'
count_1_999999 = (count_1_999_x1000 + drop_000 | count_1_999_x1000 + ins_space + count_1_999 | drop_000 + count_1_999)
("000001" @ count_1_999999).string()
'a haon'

We want a fairly large number for this to be worth it; unfortunately, memory limits get in the way, so building up in sections is the only way forward.

IOW, pynini gives no advantage over thrax.

#count_0_1000000000000 = pynini.union(*[pynini.cross(f"{i:03d}", formatter.format(i)) for i in range(0, 1000000000000)])

I can still generate list parts, though

with open("count-1-999.tsv", "w") as outf:
  for i in range(1, 1000):
    outf.write(f"{i:03d}\t{formatter.format(i)}\n")
with open("count-1-999-thousands.tsv", "w") as outf:
  for i in range(1, 1000):
    outf.write(f"{i:03d}\t{formatter.format(i * 1000)}\n")
with open("count-1-999-billions.tsv", "w") as outf:
  for i in range(1, 1000):
    outf.write(f"{i:03d}\t{formatter.format(i * 1000000000)}\n")