This repository contains an enhanced version of num2words with comprehensive Luxembourgish language support, including a powerful text normalizer for converting numbers, dates, times, and other numerical expressions to Luxembourgish text.
Since this Luxembourgish-enhanced version is not available on PyPI, you must install it directly from this GitHub repository:
git clone https://github.com/PeterGilles/num2words.git
cd num2words
pip install -e .Or install directly from GitHub:
pip install git+https://github.com/PeterGilles/num2words.gitThis version includes comprehensive Luxembourgish language support with the following features:
Language Code: lb (Luxembourgish)
Supported to options:
cardinal(default): Convert to cardinal numbers (e.g., 42 → zweeavéierzeg)ordinal: Convert to ordinal numbers (e.g., 42 → zweeavéierzegsten)ordinal_num: Convert to ordinal numbers as numerals (e.g., 42 → 42.)year: Convert to year form (e.g., 2023 → zweedausenddräianzwanzeg)currency: Convert to currency form (e.g., 1.50 EUR → eent Euro an fofzeg Cent)
Command line with Luxembourgish:
$ num2words 10001 -l lb
dausendeent
$ num2words 24,120.10 -l lb
véieranzwanzegdausendhonnertzwanzeg Komma zéng
$ num2words 24,120.35 -l lb
véieranzwanzegdausendhonnertzwanzeg Komma fënnefandrësseg
$ num2words 24.120,35 -l lb
véieranzwanzegdausendhonnertzwanzeg Komma fënnefandrësseg
$ num2words 1,234.56 -l lb
dausendzweehonnertvéierandrësseg Komma sechsafofzeg
$ num2words 1.234,56 -l lb
dausendzweehonnertvéierandrësseg Komma sechsafofzegNote: Both English-style (comma as thousands, dot as decimal) and European-style (dot as thousands, comma as decimal) number formats are supported for all decimal and large number conversions.
In Python code:
>>> from num2words import num2words
>>> num2words(42, lang='lb')
'zweeavéierzeg'
>>> num2words(42, lang='lb', to='ordinal')
'zweeavéierzegsten'
>>> num2words(2023, lang='lb', to='year')
'zweedausenddräianzwanzeg'The repository includes a comprehensive text normalizer (luxembourgish_normalizer.py) that converts various numerical expressions in Luxembourgish text to their word forms.
Installation and Usage:
python luxembourgish_normalizer.py input_file.txt
# or
echo "Your text here" | python luxembourgish_normalizer.pyThe Luxembourgish normalizer script (luxembourgish_normalizer.py) recognizes and converts the following types of expressions:
Numbers and Large Numbers - Recognizes: Standalone numbers, numbers with spaces or dots as thousand separators, numbers with decimals (dot or comma) - Converts: All numbers to their full Luxembourgish word form - Examples:
42→zweeavéierzeg1 234→dausendzweehonnertvéierandrësseg40 000→véierzegdausend24,120.35→véieranzwanzegdausendhonnertzwanzeg Komma fënnefandrësseg24.120,35→véieranzwanzegdausendhonnertzwanzeg Komma fënnefandrësseg1.234,56→dausendzweehonnertvéierandrësseg Komma sechsafofzeg
Dates and Ordinals - Recognizes: Full dates, numeric dates, ordinals with dot - Converts: Dates to Luxembourgish with correct ordinal and month, ordinals to correct form before nouns - Examples:
30. Abrëll 2010→drëssegsten Abrëll zweedausendzéng22.3.→zweeanzwanzegste Mäerz9. Plaz→néngte Plazden 1. Juni→den éischte Junide 4. Juni→de véierte Juni
Times - Recognizes: Times in
HH:MM,HHhMM, orHH.MMformat - Converts: To[hour] Auer [minute]in Luxembourgish, only for valid times (hours 0–24, minutes 0–59) - Examples:10:34→zéng Auer véierandrësseg10h34→zéng Auer véierandrësseg17.40→siwwenzéng Auer véierzeg8:15→aacht Auer fofzéng
Match Results - Recognizes: Sports scores in
X:YorX-Yformat - Converts: To[score1] zu [score2]using correct Luxembourgish number words - Examples:1:1→eent zu eent2:0→zwee zu null71:56→eenasiwwenzeg zu sechsafofzeg3-2→dräi zu zwee
Percentages - Recognizes: Numbers followed by
%(with or without space) - Converts: To[number] Prozentwith correct decimal handling - Examples:25%→fënnefanzwanzeg Prozent93,9%→dräiannonzeg Komma néng Prozent50 %→fofzeg Prozent1,25%→eent Komma fënnefanzwanzeg Prozent
Units and Measurements - Recognizes: Numbers with units (temperature, volume, weight, distance, time) - Converts: To full Luxembourgish with correct unit and number form, including feminine forms - Examples:
90°→nonzeg Grad50 kg→fofzeg Kilogramm100 ml→honnert Milliliter60 km→sechzeg Kilometer2 Stonnen→zwou Stonnen1ml→ee Milliliter500 gr→fënnefhonnert Gramm
Phone Numbers - Recognizes: Lines containing
Telefon,Tel, orPhonewith digit groups - Converts: Each digit to word, always includingnullfor zeros and leading zeros - Examples:Tel: 08 123 456→Tel: null aacht eent zwee dräi véier fënnef sechsTelefon: 352 123 456→Telefon: dräi fënnef zwee eent zwee dräi véier fënnef sechs
Abbreviations - Recognizes: 2+ consecutive uppercase letters - Converts: To Luxembourgish letter pronunciation, or as a word if in custom dictionary - Examples:
VW→FAUWEECSV→ZEEÄSSFAUFIFA→FIFA(custom dictionary word)NATO→NATO(custom dictionary word)
Years with Suffixes - Recognizes: Decades like
1970er,80er- Converts: To full Luxembourgish decade form - Examples:1970er→nonzénghonnertsiwwenzeger1980er→nonzénghonnertachtzeger80er→achtzegeran den 1970er Joren→an den nonzénghonnertsiwwenzeger Joren
Currency - Recognizes: Numbers with currency codes or symbols (EUR, €, USD, $, GBP, £, etc.) - Converts: To full Luxembourgish currency form with correct grammar - Examples:
1,50 EUR→een Euro a fofzeg Cent1,50€→een Euro a fofzeg Cent1.50 EUR→een Euro a fofzeg Cent2,25 USD→zwee Dollar a fënnefanzwanzeg Cent1,01 GBP→ee Pond an ee Pennyhuet 1,50 EUR kritt→huet een Euro a fofzeg Cent kritt
Each normalization type is context-aware and applies Luxembourgish grammar and phonological rules for natural, correct output. The normalizer handles both European-style (comma as decimal) and English-style (dot as decimal) number formats.