Replace format and parse calls with lingua-franca
parent
aa86e10ca3
commit
1b88db4fa1
|
@ -1,132 +0,0 @@
|
|||
{
|
||||
"decade_format": {
|
||||
"1": {"match": "^1$", "format": "et"},
|
||||
"2": {"match": "^\\d$", "format": "{x}"},
|
||||
"3": {"match": "^1\\d$", "format": "{xx}"},
|
||||
"4": {"match": "^\\d0$", "format": "{x0}"},
|
||||
"5": {"match": "^[2-9]\\d$", "format": "{x} og {x0}"},
|
||||
"default": "{number}"
|
||||
},
|
||||
"hundreds_format": {
|
||||
"1": {"match": "^1\\d{2}$", "format": "et hundred"},
|
||||
"2": {"match": "^\\d{3}$", "format": "{x_in_x00} hundred"},
|
||||
"default": "{number}"
|
||||
},
|
||||
"thousand_format": {
|
||||
"1": {"match": "^1[1-9]\\d{2}$", "format": "{xx_in_xx00} hundred"},
|
||||
"2": {"match": "^1\\d{3}$", "format": "et tusind"},
|
||||
"3": {"match": "^\\d{4}$", "format": "{x_in_x000} tusind"},
|
||||
"default": "{number}"
|
||||
},
|
||||
"year_format": {
|
||||
"1": {"match": "^\\d\\d?$", "format": "{formatted_decade} {bc}"},
|
||||
"2": {"match": "^\\d00$", "format": "{formatted_hundreds} {bc}"},
|
||||
"3": {"match": "^\\d{3}$", "format": "{formatted_hundreds} og {formatted_decade} {bc}"},
|
||||
"4": {"match": "^(1\\d00)|([2-9]000)$", "format": "{formatted_thousand} {bc}"},
|
||||
"5": {"match": "^(1\\d{3})|(\\d0\\d{2})$", "format": "{formatted_thousand} og {formatted_decade} {bc}"},
|
||||
"6": {"match": "^\\d{4}$", "format": "{formatted_thousand} {formatted_hundreds} og {formatted_decade} {bc}"},
|
||||
"default": "{year} {bc}",
|
||||
"bc": "f.kr."
|
||||
},
|
||||
"date_format": {
|
||||
"date_full": "{weekday}, den {day} {month}, {formatted_year}",
|
||||
"date_full_no_year": "{weekday}, den {day} {month}",
|
||||
"date_full_no_year_month": "{weekday}, den {day}",
|
||||
"today": "i dag",
|
||||
"tomorrow": "i morgen",
|
||||
"yesterday": "i går"
|
||||
},
|
||||
"date_time_format": {
|
||||
"date_time": "{formatted_date} klokken {formatted_time}"
|
||||
},
|
||||
"weekday": {
|
||||
"0": "mandag",
|
||||
"1": "tirsdag",
|
||||
"2": "onsdag",
|
||||
"3": "torsdag",
|
||||
"4": "fredag",
|
||||
"5": "lørdag",
|
||||
"6": "søndag"
|
||||
},
|
||||
"date": {
|
||||
"1": "første",
|
||||
"2": "anden",
|
||||
"3": "tredie",
|
||||
"4": "fjerde",
|
||||
"5": "femte",
|
||||
"6": "sjette",
|
||||
"7": "syvende",
|
||||
"8": "ottende",
|
||||
"9": "ninende",
|
||||
"10": "tiende",
|
||||
"11": "elvte",
|
||||
"12": "tolvte",
|
||||
"13": "trettende",
|
||||
"14": "fjortende",
|
||||
"15": "femtende",
|
||||
"16": "sekstende",
|
||||
"17": "syttende",
|
||||
"18": "attende",
|
||||
"19": "nittende",
|
||||
"20": "tyvende",
|
||||
"21": "en og tyvende",
|
||||
"22": "to og tyvende",
|
||||
"23": "tre og tyvende",
|
||||
"24": "fire og tyvende",
|
||||
"25": "fem og tyvende",
|
||||
"26": "seks og tyvende",
|
||||
"27": "syv og tyvende",
|
||||
"28": "otte og tyvende",
|
||||
"29": "ni og tyvende",
|
||||
"30": "tredivte",
|
||||
"31": "en og tredivte"
|
||||
},
|
||||
"month": {
|
||||
"1": "januar",
|
||||
"2": "februar",
|
||||
"3": "marts",
|
||||
"4": "april",
|
||||
"5": "maj",
|
||||
"6": "juni",
|
||||
"7": "juli",
|
||||
"8": "august",
|
||||
"9": "september",
|
||||
"10": "oktober",
|
||||
"11": "november",
|
||||
"12": "december"
|
||||
},
|
||||
"number": {
|
||||
"0": "nul",
|
||||
"1": "en",
|
||||
"2": "to",
|
||||
"3": "tre",
|
||||
"4": "fire",
|
||||
"5": "fem",
|
||||
"6": "seks",
|
||||
"7": "syv",
|
||||
"8": "otte",
|
||||
"9": "ni",
|
||||
"10": "ti",
|
||||
"11": "elve",
|
||||
"12": "tolv",
|
||||
"13": "tretten",
|
||||
"14": "fjorten",
|
||||
"15": "femten",
|
||||
"16": "seksten",
|
||||
"17": "sytten",
|
||||
"18": "atten",
|
||||
"19": "nitten",
|
||||
"20": "tyve",
|
||||
"30": "tredive",
|
||||
"40": "fyrre",
|
||||
"50": "halvtreds",
|
||||
"60": "treds",
|
||||
"70": "halvfjerds",
|
||||
"80": "firs",
|
||||
"90": "halvfems",
|
||||
"100": "hundrede",
|
||||
"1000": "tusind",
|
||||
"2000": "to tusind"
|
||||
}
|
||||
|
||||
}
|
|
@ -1,136 +0,0 @@
|
|||
{
|
||||
"decade_format": {
|
||||
"1": {"match": "^\\d$", "format": "{x}"},
|
||||
"2": {"match": "^1\\d$", "format": "{xx}"},
|
||||
"3": {"match": "^\\d0$", "format": "{x0}"},
|
||||
"4": {"match": "^[2-9]\\d$", "format": "{x} und {x0}"},
|
||||
"default": "{number}"
|
||||
},
|
||||
"hundreds_format": {
|
||||
"1": {"match": "^1\\d{2}$", "format": "hundert"},
|
||||
"2": {"match": "^\\d{3}$", "format": "{x_in_x00} hundert"},
|
||||
"default": "{number}"
|
||||
},
|
||||
"thousand_format": {
|
||||
"1": {"match": "^10\\d\\d$", "format": "tausend"},
|
||||
"2": {"match": "^\\d0\\d{2}$", "format": "{x_in_x000} tausend"},
|
||||
"3": {"match": "^1\\d00$", "format": "{xx_in_xx00} hundert"},
|
||||
"4": {"match": "^\\d{2}00$", "format": "{x_in_x000} tausend {x_in_x00} hundert"},
|
||||
"5": {"match": "^\\d0\\d\\d$", "format": "{x_in_x000} tausend"},
|
||||
"6": {"match": "^1\\d{3}$", "format": "{xx_in_xx00}"},
|
||||
"7": {"match": "^\\d{4}$", "format": "{x_in_x000} tausend {x_in_x00} hundert"},
|
||||
"default": "{number}"
|
||||
},
|
||||
"year_format": {
|
||||
"1": {"match": "^1$", "format": "eins {bc}"},
|
||||
"2": {"match": "^\\d{1}?$", "format": "{formatted_decade} {bc}"},
|
||||
"3": {"match": "^\\d{2}?$", "format": "{formatted_decade} {bc}"},
|
||||
"4": {"match": "^\\d00$", "format": "{formatted_hundreds} {bc}"},
|
||||
"5": {"match": "^\\d{3}$", "format": "{formatted_hundreds} {formatted_decade} {bc}"},
|
||||
"6": {"match": "^\\d{2}00$", "format": "{formatted_thousand} {bc}"},
|
||||
"7": {"match": "^\\d00\\d$", "format": "{formatted_thousand} {formatted_decade} {bc}"},
|
||||
"8": {"match": "^\\d{2}0\\d$", "format": "{formatted_thousand} hundert {formatted_decade} {bc}"},
|
||||
"9": {"match": "^1[2-9]\\d{2}$", "format": "{formatted_thousand} hundert {formatted_decade} {bc}"},
|
||||
"10": {"match": "^1\\d{3}$", "format": "{formatted_thousand} {formatted_decade} {bc}"},
|
||||
"11": {"match": "^\\d{4}$", "format": "{formatted_thousand} {formatted_decade} {bc}"},
|
||||
"default": "{year} {bc}",
|
||||
"bc": "v.d.Z."
|
||||
},
|
||||
"date_format": {
|
||||
"date_full": "{weekday}, {day} {month}, {formatted_year}",
|
||||
"date_full_no_year": "{weekday}, {day} {month}",
|
||||
"date_full_no_year_month": "{weekday}, {day}",
|
||||
"today": "heute",
|
||||
"tomorrow": "morgen",
|
||||
"yesterday": "gestern"
|
||||
},
|
||||
"date_time_format": {
|
||||
"date_time": "{formatted_date} um {formatted_time}"
|
||||
},
|
||||
"weekday": {
|
||||
"0": "Montag",
|
||||
"1": "Dienstag",
|
||||
"2": "Mittwoch",
|
||||
"3": "Donnerstag",
|
||||
"4": "Freitag",
|
||||
"5": "Samstag",
|
||||
"6": "Sonntag"
|
||||
},
|
||||
"date": {
|
||||
"1": "erster",
|
||||
"2": "zweiter",
|
||||
"3": "dritter",
|
||||
"4": "vierter",
|
||||
"5": "fünfter",
|
||||
"6": "sechster",
|
||||
"7": "siebter",
|
||||
"8": "achter",
|
||||
"9": "neunter",
|
||||
"10": "zehnter",
|
||||
"11": "elfter",
|
||||
"12": "zwölfter",
|
||||
"13": "dreizehnter",
|
||||
"14": "vierzehnter",
|
||||
"15": "fünfzehnter",
|
||||
"16": "sechzehnter",
|
||||
"17": "siebzehnter",
|
||||
"18": "achzehnter",
|
||||
"19": "neunzehnter",
|
||||
"20": "zwanzigster",
|
||||
"21": "einundzwanzigster",
|
||||
"22": "zweiundzwanzigster",
|
||||
"23": "dreiundzwanzigster",
|
||||
"24": "vierundzwanzigster",
|
||||
"25": "fünfundzwanzigster",
|
||||
"26": "sechsundzwanzigster",
|
||||
"27": "siebenundzwanzigster",
|
||||
"28": "achtundzwanzigster",
|
||||
"29": "neunundzwnzigster",
|
||||
"30": "dreißigster",
|
||||
"31": "einunddreißigster"
|
||||
},
|
||||
"month": {
|
||||
"1": "Januar",
|
||||
"2": "Februar",
|
||||
"3": "März",
|
||||
"4": "April",
|
||||
"5": "Mai",
|
||||
"6": "Juni",
|
||||
"7": "Juli",
|
||||
"8": "August",
|
||||
"9": "September",
|
||||
"10": "Oktober",
|
||||
"11": "November",
|
||||
"12": "Dezember"
|
||||
},
|
||||
"number": {
|
||||
"0": "null",
|
||||
"1": "ein",
|
||||
"2": "zwei",
|
||||
"3": "drei",
|
||||
"4": "vier",
|
||||
"5": "fünf",
|
||||
"6": "sechs",
|
||||
"7": "sieben",
|
||||
"8": "acht",
|
||||
"9": "neun",
|
||||
"10": "zehn",
|
||||
"11": "elf",
|
||||
"12": "zwölf",
|
||||
"13": "dreizehn",
|
||||
"14": "vierzehn",
|
||||
"15": "fünfzehn",
|
||||
"16": "sechzehn",
|
||||
"17": "siebzehn",
|
||||
"18": "achzehn",
|
||||
"19": "neunzehn",
|
||||
"20": "zwanzig",
|
||||
"30": "dreißig",
|
||||
"40": "vierzig",
|
||||
"50": "fünfzig",
|
||||
"60": "sechzig",
|
||||
"70": "siebzig",
|
||||
"80": "achzig",
|
||||
"90": "neunzig"
|
||||
}
|
||||
}
|
|
@ -1,129 +0,0 @@
|
|||
{
|
||||
"decade_format": {
|
||||
"1": {"match": "^\\d$", "format": "{x}"},
|
||||
"2": {"match": "^1\\d$", "format": "{xx}"},
|
||||
"3": {"match": "^\\d0$", "format": "{x0}"},
|
||||
"4": {"match": "^[2-9]\\d$", "format": "{x0} {x}"},
|
||||
"default": "{number}"
|
||||
},
|
||||
"hundreds_format": {
|
||||
"1": {"match": "^\\d{3}$", "format": "{x_in_x00} hundred"},
|
||||
"default": "{number}"
|
||||
},
|
||||
"thousand_format": {
|
||||
"1": {"match": "^\\d00\\d$", "format": "{x_in_x000} thousand"},
|
||||
"2": {"match": "^1\\d00$", "format": "{xx_in_xx00} hundred"},
|
||||
"3": {"match": "^\\d{2}00$", "format": "{x0_in_x000} {x_in_x00} hundred"},
|
||||
"4": {"match": "^(1\\d{3})|(\\d0\\d{2})$", "format": "{xx_in_xx00}"},
|
||||
"5": {"match": "^\\d{4}$", "format": "{x0_in_x000} {x_in_x00}"},
|
||||
"default": "{number}"
|
||||
},
|
||||
"year_format": {
|
||||
"1": {"match": "^\\d\\d?$", "format": "{formatted_decade} {bc}"},
|
||||
"2": {"match": "^\\d00$", "format": "{formatted_hundreds} {bc}"},
|
||||
"3": {"match": "^\\d{3}$", "format": "{formatted_hundreds} {formatted_decade} {bc}"},
|
||||
"4": {"match": "^\\d{2}00$", "format": "{formatted_thousand} {bc}"},
|
||||
"5": {"match": "^\\d00\\d$", "format": "{formatted_thousand} {formatted_decade} {bc}"},
|
||||
"6": {"match": "^\\d{2}0\\d$", "format": "{formatted_thousand} oh {formatted_decade} {bc}"},
|
||||
"7": {"match": "^\\d{4}$", "format": "{formatted_thousand} {formatted_decade} {bc}"},
|
||||
"default": "{year} {bc}",
|
||||
"bc": "b.c."
|
||||
},
|
||||
"date_format": {
|
||||
"date_full": "{weekday}, {month} {day}, {formatted_year}",
|
||||
"date_full_no_year": "{weekday}, {month} {day}",
|
||||
"date_full_no_year_month": "{weekday}, {day}",
|
||||
"today": "today",
|
||||
"tomorrow": "tomorrow",
|
||||
"yesterday": "yesterday"
|
||||
},
|
||||
"date_time_format": {
|
||||
"date_time": "{formatted_date} at {formatted_time}"
|
||||
},
|
||||
"weekday": {
|
||||
"0": "monday",
|
||||
"1": "tuesday",
|
||||
"2": "wednesday",
|
||||
"3": "thursday",
|
||||
"4": "friday",
|
||||
"5": "saturday",
|
||||
"6": "sunday"
|
||||
},
|
||||
"date": {
|
||||
"1": "first",
|
||||
"2": "second",
|
||||
"3": "third",
|
||||
"4": "fourth",
|
||||
"5": "fifth",
|
||||
"6": "sixth",
|
||||
"7": "seventh",
|
||||
"8": "eighth",
|
||||
"9": "ninth",
|
||||
"10": "tenth",
|
||||
"11": "eleventh",
|
||||
"12": "twelfth",
|
||||
"13": "thirteenth",
|
||||
"14": "fourteenth",
|
||||
"15": "fifteenth",
|
||||
"16": "sixteenth",
|
||||
"17": "seventeenth",
|
||||
"18": "eighteenth",
|
||||
"19": "nineteenth",
|
||||
"20": "twentieth",
|
||||
"21": "twenty-first",
|
||||
"22": "twenty-second",
|
||||
"23": "twenty-third",
|
||||
"24": "twenty-fourth",
|
||||
"25": "twenty-fifth",
|
||||
"26": "twenty-sixth",
|
||||
"27": "twenty-seventh",
|
||||
"28": "twenty-eighth",
|
||||
"29": "twenty-ninth",
|
||||
"30": "thirtieth",
|
||||
"31": "thirty-first"
|
||||
},
|
||||
"month": {
|
||||
"1": "january",
|
||||
"2": "february",
|
||||
"3": "march",
|
||||
"4": "april",
|
||||
"5": "may",
|
||||
"6": "june",
|
||||
"7": "july",
|
||||
"8": "august",
|
||||
"9": "september",
|
||||
"10": "october",
|
||||
"11": "november",
|
||||
"12": "december"
|
||||
},
|
||||
"number": {
|
||||
"0": "zero",
|
||||
"1": "one",
|
||||
"2": "two",
|
||||
"3": "three",
|
||||
"4": "four",
|
||||
"5": "five",
|
||||
"6": "six",
|
||||
"7": "seven",
|
||||
"8": "eight",
|
||||
"9": "nine",
|
||||
"10": "ten",
|
||||
"11": "eleven",
|
||||
"12": "twelve",
|
||||
"13": "thirteen",
|
||||
"14": "fourteen",
|
||||
"15": "fifteen",
|
||||
"16": "sixteen",
|
||||
"17": "seventeen",
|
||||
"18": "eighteen",
|
||||
"19": "nineteen",
|
||||
"20": "twenty",
|
||||
"30": "thirty",
|
||||
"40": "forty",
|
||||
"50": "fifty",
|
||||
"60": "sixty",
|
||||
"70": "seventy",
|
||||
"80": "eighty",
|
||||
"90": "ninety"
|
||||
}
|
||||
}
|
|
@ -1,129 +0,0 @@
|
|||
{
|
||||
"decade_format": {
|
||||
"1": {"match": "^\\d$", "format": "{x}"},
|
||||
"2": {"match": "^1\\d$", "format": "{xx}"},
|
||||
"3": {"match": "^\\d0$", "format": "{x0}"},
|
||||
"4": {"match": "^[2-9]\\d$", "format": "{x0} {x}"},
|
||||
"default": "{number}"
|
||||
},
|
||||
"hundreds_format": {
|
||||
"1": {"match": "^\\d{3}$", "format": "{x_in_x00} hundred"},
|
||||
"default": "{number}"
|
||||
},
|
||||
"thousand_format": {
|
||||
"1": {"match": "^\\d00\\d$", "format": "{x_in_x000} thousand"},
|
||||
"2": {"match": "^1\\d00$", "format": "{xx_in_xx00} hundred"},
|
||||
"3": {"match": "^\\d{2}00$", "format": "{x0_in_x000} {x_in_x00} hundred"},
|
||||
"4": {"match": "^(1\\d{3})|(\\d0\\d{2})$", "format": "{xx_in_xx00}"},
|
||||
"5": {"match": "^\\d{4}$", "format": "{x0_in_x000} {x_in_x00}"},
|
||||
"default": "{number}"
|
||||
},
|
||||
"year_format": {
|
||||
"1": {"match": "^\\d\\d?$", "format": "{formatted_decade} {bc}"},
|
||||
"2": {"match": "^\\d00$", "format": "{formatted_hundreds} {bc}"},
|
||||
"3": {"match": "^\\d{3}$", "format": "{formatted_hundreds} {formatted_decade} {bc}"},
|
||||
"4": {"match": "^\\d{2}00$", "format": "{formatted_thousand} {bc}"},
|
||||
"5": {"match": "^\\d00\\d$", "format": "{formatted_thousand} {formatted_decade} {bc}"},
|
||||
"6": {"match": "^\\d{2}0\\d$", "format": "{formatted_thousand} oh {formatted_decade} {bc}"},
|
||||
"7": {"match": "^\\d{4}$", "format": "{formatted_thousand} {formatted_decade} {bc}"},
|
||||
"default": "{year} {bc}",
|
||||
"bc": "b.c."
|
||||
},
|
||||
"date_format": {
|
||||
"date_full": "{weekday}, {month} {day}, {formatted_year}",
|
||||
"date_full_no_year": "{weekday}, {month} {day}",
|
||||
"date_full_no_year_month": "{weekday}, the {day}",
|
||||
"today": "today",
|
||||
"tomorrow": "tomorrow",
|
||||
"yesterday": "yesterday"
|
||||
},
|
||||
"date_time_format": {
|
||||
"date_time": "{formatted_date} at {formatted_time}"
|
||||
},
|
||||
"weekday": {
|
||||
"0": "monday",
|
||||
"1": "tuesday",
|
||||
"2": "wednesday",
|
||||
"3": "thursday",
|
||||
"4": "friday",
|
||||
"5": "saturday",
|
||||
"6": "sunday"
|
||||
},
|
||||
"date": {
|
||||
"1": "first",
|
||||
"2": "second",
|
||||
"3": "third",
|
||||
"4": "fourth",
|
||||
"5": "fifth",
|
||||
"6": "sixth",
|
||||
"7": "seventh",
|
||||
"8": "eighth",
|
||||
"9": "ninth",
|
||||
"10": "tenth",
|
||||
"11": "eleventh",
|
||||
"12": "twelfth",
|
||||
"13": "thirteenth",
|
||||
"14": "fourteenth",
|
||||
"15": "fifteenth",
|
||||
"16": "sixteenth",
|
||||
"17": "seventeenth",
|
||||
"18": "eighteenth",
|
||||
"19": "nineteenth",
|
||||
"20": "twentieth",
|
||||
"21": "twenty-first",
|
||||
"22": "twenty-second",
|
||||
"23": "twenty-third",
|
||||
"24": "twenty-fourth",
|
||||
"25": "twenty-fifth",
|
||||
"26": "twenty-sixth",
|
||||
"27": "twenty-seventh",
|
||||
"28": "twenty-eighth",
|
||||
"29": "twenty-ninth",
|
||||
"30": "thirtieth",
|
||||
"31": "thirty-first"
|
||||
},
|
||||
"month": {
|
||||
"1": "january",
|
||||
"2": "february",
|
||||
"3": "march",
|
||||
"4": "april",
|
||||
"5": "may",
|
||||
"6": "june",
|
||||
"7": "july",
|
||||
"8": "august",
|
||||
"9": "september",
|
||||
"10": "october",
|
||||
"11": "november",
|
||||
"12": "december"
|
||||
},
|
||||
"number": {
|
||||
"0": "zero",
|
||||
"1": "one",
|
||||
"2": "two",
|
||||
"3": "three",
|
||||
"4": "four",
|
||||
"5": "five",
|
||||
"6": "six",
|
||||
"7": "seven",
|
||||
"8": "eight",
|
||||
"9": "nine",
|
||||
"10": "ten",
|
||||
"11": "eleven",
|
||||
"12": "twelve",
|
||||
"13": "thirteen",
|
||||
"14": "fourteen",
|
||||
"15": "fifteen",
|
||||
"16": "sixteen",
|
||||
"17": "seventeen",
|
||||
"18": "eighteen",
|
||||
"19": "nineteen",
|
||||
"20": "twenty",
|
||||
"30": "thirty",
|
||||
"40": "forty",
|
||||
"50": "fifty",
|
||||
"60": "sixty",
|
||||
"70": "seventy",
|
||||
"80": "eighty",
|
||||
"90": "ninety"
|
||||
}
|
||||
}
|
|
@ -1,132 +0,0 @@
|
|||
{
|
||||
"decade_format": {
|
||||
"1": {"match": "^\\d$", "format": "{x}"},
|
||||
"2": {"match": "^1\\d$", "format": "{xx}"},
|
||||
"3": {"match": "^20$", "format": "húsz"},
|
||||
"4": {"match": "^\\d0$", "format": "{x0}"},
|
||||
"5": {"match": "^[2-9]\\d$", "format": "{x0}{x}"},
|
||||
"default": "{number}"
|
||||
},
|
||||
"hundreds_format": {
|
||||
"1": {"match": "^2\\d{2}$", "format": "kétszáz"},
|
||||
"2": {"match": "^\\d{3}$", "format": "{x_in_x00}száz"},
|
||||
"default": "{number}"
|
||||
},
|
||||
"thousand_format": {
|
||||
"1": {"match": "^1\\d{3}$", "format": "ezer"},
|
||||
"2": {"match": "^2\\d{3}$", "format": "kétezer"},
|
||||
"3": {"match": "^\\d{4}$", "format": "{x_in_x000}ezer"},
|
||||
"default": "{number}"
|
||||
},
|
||||
"year_format": {
|
||||
"1": {"match": "^\\d\\d?$", "format": "{bc} {formatted_decade}"},
|
||||
"2": {"match": "^\\d000$", "format": "{bc} {formatted_thousand}"},
|
||||
"3": {"match": "^\\d{3}$", "format": "{bc} {formatted_hundreds}{formatted_decade}"},
|
||||
"4": {"match": "^[2-9]\\d00$", "format": "{bc} {formatted_thousand}-{formatted_hundreds}"},
|
||||
"5": {"match": "^1[0-9]00$", "format": "{bc} {formatted_thousand}{formatted_hundreds}"},
|
||||
"6": {"match": "^[2-9]0\\d{2}$", "format": "{bc} {formatted_thousand}-{formatted_decade}"},
|
||||
"7": {"match": "^10\\d{2}$", "format": "{bc} {formatted_thousand}{formatted_decade}"},
|
||||
"8": {"match": "^[2-9]00\\d$", "format": "{bc} {formatted_thousand}{formatted_decade}"},
|
||||
"9": {"match": "^1\\d{3}$", "format": "{bc} {formatted_thousand}{formatted_hundreds}{formatted_decade}"},
|
||||
"10": {"match": "^[2-9]\\d{3}$", "format": "{bc} {formatted_thousand}-{formatted_hundreds}{formatted_decade}"},
|
||||
"default": "{bc} {year}",
|
||||
"bc": "kr.e."
|
||||
},
|
||||
"date_format": {
|
||||
"date_full": "{formatted_year} {month} {day}, {weekday}",
|
||||
"date_full_no_year": "{month} {day}, {weekday}",
|
||||
"date_full_no_year_month": "{day}, {weekday}",
|
||||
"today": "ma",
|
||||
"tomorrow": "holnap",
|
||||
"yesterday": "tegnap"
|
||||
},
|
||||
"date_time_format": {
|
||||
"date_time": "{formatted_date}, {formatted_time}"
|
||||
},
|
||||
"weekday": {
|
||||
"0": "hétfő",
|
||||
"1": "kedd",
|
||||
"2": "szerda",
|
||||
"3": "csütörtök",
|
||||
"4": "péntek",
|
||||
"5": "szombat",
|
||||
"6": "vasárnap"
|
||||
},
|
||||
"date": {
|
||||
"1": "elseje",
|
||||
"2": "másodika",
|
||||
"3": "harmadika",
|
||||
"4": "negyedike",
|
||||
"5": "ötödike",
|
||||
"6": "hatodika",
|
||||
"7": "hetedike",
|
||||
"8": "nyolcadika",
|
||||
"9": "kilencedike",
|
||||
"10": "tizedike",
|
||||
"11": "tizenegyedike",
|
||||
"12": "tizenkettedike",
|
||||
"13": "tizenharmadika",
|
||||
"14": "tizennegyedike",
|
||||
"15": "tizenötödike",
|
||||
"16": "tizenhatodika",
|
||||
"17": "tizenhetedike",
|
||||
"18": "tizennyolcadika",
|
||||
"19": "tizenkilencedike",
|
||||
"20": "huszadika",
|
||||
"21": "huszonegyedike",
|
||||
"22": "huszonkettedike",
|
||||
"23": "huszonharmadika",
|
||||
"24": "huszonnegyedike",
|
||||
"25": "huszonötödike",
|
||||
"26": "huszonhatodika",
|
||||
"27": "huszonhetedike",
|
||||
"28": "huszonnyolcadika",
|
||||
"29": "huszonkilencedike",
|
||||
"30": "harmincadika",
|
||||
"31": "harmincegyedike"
|
||||
},
|
||||
"month": {
|
||||
"1": "január",
|
||||
"2": "február",
|
||||
"3": "március",
|
||||
"4": "április",
|
||||
"5": "május",
|
||||
"6": "június",
|
||||
"7": "július",
|
||||
"8": "augusztus",
|
||||
"9": "szeptember",
|
||||
"10": "október",
|
||||
"11": "november",
|
||||
"12": "december"
|
||||
},
|
||||
"number": {
|
||||
"0": "nulla",
|
||||
"1": "egy",
|
||||
"2": "kettő",
|
||||
"3": "három",
|
||||
"4": "négy",
|
||||
"5": "öt",
|
||||
"6": "hat",
|
||||
"7": "hét",
|
||||
"8": "nyolc",
|
||||
"9": "kilenc",
|
||||
"10": "tíz",
|
||||
"11": "tizenegy",
|
||||
"12": "tizenkettő",
|
||||
"13": "tizenhárom",
|
||||
"14": "tizennégy",
|
||||
"15": "tizenöt",
|
||||
"16": "tizenhat",
|
||||
"17": "tizenhét",
|
||||
"18": "tizennyolc",
|
||||
"19": "tizenkilenc",
|
||||
"20": "huszon",
|
||||
"30": "harminc",
|
||||
"40": "negyven",
|
||||
"50": "ötven",
|
||||
"60": "hatvan",
|
||||
"70": "hetven",
|
||||
"80": "nyolcvan",
|
||||
"90": "kilencven"
|
||||
}
|
||||
}
|
|
@ -1,153 +0,0 @@
|
|||
{
|
||||
"decade_format": {
|
||||
"1": {"match": "^\\d$", "format": "{x}"},
|
||||
"2": {"match": "^1\\d$", "format": "{xx}"},
|
||||
"3": {"match": "^\\d0$", "format": "{x0}"},
|
||||
"4": {"match": "^[2-9][1|8]", "format": "{xx}"},
|
||||
"5": {"match": "^[2-9]\\d$", "format": "{x0}{x}"},
|
||||
"default": "{number}"
|
||||
},
|
||||
"hundreds_format": {
|
||||
"1": {"match": "^1\\d{2}$", "format": "cento"},
|
||||
"2": {"match": "^\\d{3}$", "format": "{x_in_x00}cento"},
|
||||
"default": "{number}"
|
||||
},
|
||||
"thousand_format": {
|
||||
"1": {"match": "^1\\d{3}$", "format": "mille"},
|
||||
"2": {"match": "^\\d{4}$", "format": "{x_in_x000}mila"},
|
||||
"default": "{number}"
|
||||
},
|
||||
"year_format": {
|
||||
"1": {"match": "^\\d\\d?$", "format": "{formatted_decade} {bc}"},
|
||||
"2": {"match": "^\\d00$", "format": "{formatted_hundreds} {bc}"},
|
||||
"3": {"match": "^\\d000$", "format": "{formatted_thousand} {bc}"},
|
||||
"4": {"match": "^\\d{3}$", "format": "{formatted_hundreds} {formatted_decade} {bc}"},
|
||||
"5": {"match": "^1[0-9]00$", "format": "{formatted_thousand} {formatted_hundreds} {bc}"},
|
||||
"6": {"match": "^10\\d{2}$", "format": "{formatted_thousand} e {formatted_decade} {bc}"},
|
||||
"7": {"match": "^[2-9][0-9]00$", "format": "{formatted_thousand} {formatted_hundreds} {bc}"},
|
||||
"8": {"match": "^20\\d{2}$", "format": "{formatted_thousand} {formatted_decade} {bc}"},
|
||||
"9": {"match": "^(1\\d{3})|(\\d0\\d{2})$", "format": "{formatted_thousand} {formatted_hundreds} {formatted_decade} {bc}"},
|
||||
"10": {"match": "^[2-9]000$", "format": "{formatted_thousand} {bc}"},
|
||||
"11": {"match": "^20\\d{2}$", "format": "{formatted_thousand} {formatted_decade} {bc}"},
|
||||
"12": {"match": "^([2-9]\\d{3})|(\\d0\\d{2})$", "format": "{formatted_thousand} {formatted_hundreds} {formatted_decade} {bc}"},
|
||||
"13": {"match": "^\\d{4}$", "format": "{formatted_thousand} {formatted_hundreds} {formatted_decade} {bc}"},
|
||||
"default": "{year} {bc}",
|
||||
"bc": "d.c."
|
||||
},
|
||||
"date_format": {
|
||||
"date_full": "{weekday}, {day} {month}, {formatted_year}",
|
||||
"date_full_no_year": "{weekday}, {day} {month}",
|
||||
"date_full_no_year_month": "{weekday}, {day}",
|
||||
"today": "oggi",
|
||||
"tomorrow": "domani",
|
||||
"yesterday": "ieri"
|
||||
},
|
||||
"date_time_format": {
|
||||
"date_time": "{formatted_date} alle {formatted_time}"
|
||||
},
|
||||
"weekday": {
|
||||
"0": "lunedì",
|
||||
"1": "martedì",
|
||||
"2": "mercoledì",
|
||||
"3": "giovedì",
|
||||
"4": "venerdì",
|
||||
"5": "sabato",
|
||||
"6": "domenica"
|
||||
},
|
||||
"date": {
|
||||
"1": "primo",
|
||||
"2": "due",
|
||||
"3": "tre",
|
||||
"4": "quattro",
|
||||
"5": "cinque",
|
||||
"6": "sei",
|
||||
"7": "sette",
|
||||
"8": "otto",
|
||||
"9": "nove",
|
||||
"10": "dieci",
|
||||
"11": "undici",
|
||||
"12": "dodici",
|
||||
"13": "tredici",
|
||||
"14": "quattordici",
|
||||
"15": "quindici",
|
||||
"16": "sedici",
|
||||
"17": "diciassette",
|
||||
"18": "diciotto",
|
||||
"19": "diciannove",
|
||||
"20": "venti",
|
||||
"21": "ventuno",
|
||||
"22": "ventidue",
|
||||
"23": "ventitre",
|
||||
"24": "ventiquattro",
|
||||
"25": "venticinque",
|
||||
"26": "ventisei",
|
||||
"27": "ventisette",
|
||||
"28": "ventotto",
|
||||
"29": "ventinove",
|
||||
"30": "trenta",
|
||||
"31": "trentuno"
|
||||
},
|
||||
"month": {
|
||||
"1": "gennaio",
|
||||
"2": "febbraio",
|
||||
"3": "marzo",
|
||||
"4": "aprile",
|
||||
"5": "maggio",
|
||||
"6": "giugno",
|
||||
"7": "luglio",
|
||||
"8": "agosto",
|
||||
"9": "settembre",
|
||||
"10": "ottobre",
|
||||
"11": "novembre",
|
||||
"12": "dicembre"
|
||||
},
|
||||
"number": {
|
||||
"0": "zero",
|
||||
"1": "uno",
|
||||
"2": "due",
|
||||
"3": "tre",
|
||||
"4": "quattro",
|
||||
"5": "cinque",
|
||||
"6": "sei",
|
||||
"7": "sette",
|
||||
"8": "otto",
|
||||
"9": "nove",
|
||||
"10": "dieci",
|
||||
"11": "undici",
|
||||
"12": "dodici",
|
||||
"13": "tredici",
|
||||
"14": "quattordici",
|
||||
"15": "quindici",
|
||||
"16": "sedici",
|
||||
"17": "diciassette",
|
||||
"18": "diciotto",
|
||||
"19": "diciannove",
|
||||
"20": "venti",
|
||||
"21": "ventuno",
|
||||
"28": "ventotto",
|
||||
"30": "trenta",
|
||||
"31": "trentuno",
|
||||
"38": "trentotto",
|
||||
"40": "quaranta",
|
||||
"41": "quarantuno",
|
||||
"48": "quarantotto",
|
||||
"50": "cinquanta",
|
||||
"51": "cinquantuno",
|
||||
"58": "cinquantotto",
|
||||
"60": "sessanta",
|
||||
"61": "sessantuno",
|
||||
"68": "sessantotto",
|
||||
"70": "settanta",
|
||||
"71": "settantuno",
|
||||
"78": "settantotto",
|
||||
"80": "ottanta",
|
||||
"81": "ottantuno",
|
||||
"88": "ottantotto",
|
||||
"90": "novanta",
|
||||
"91": "novantuno",
|
||||
"98": "novantotto",
|
||||
"100": "cento",
|
||||
"1000": "mille",
|
||||
"2000": "duemila"
|
||||
}
|
||||
}
|
|
@ -1,136 +0,0 @@
|
|||
{
|
||||
"decade_format": {
|
||||
"1": {"match": "^\\d$", "format": "{x}"},
|
||||
"2": {"match": "^1\\d$", "format": "{xx}"},
|
||||
"3": {"match": "^\\d0$", "format": "{x0}"},
|
||||
"4": {"match": "^[2-9]\\d$", "format": "{x} en {x0}"},
|
||||
"default": "{number}"
|
||||
},
|
||||
"hundreds_format": {
|
||||
"1": {"match": "^1\\d{2}$", "format": "honderd"},
|
||||
"2": {"match": "^\\d{3}$", "format": "{x_in_x00} honderd"},
|
||||
"default": "{number}"
|
||||
},
|
||||
"thousand_format": {
|
||||
"1": {"match": "^10\\d\\d$", "format": "duizend"},
|
||||
"2": {"match": "^\\d0\\d{2}$", "format": "{x_in_x000} duizend"},
|
||||
"3": {"match": "^1\\d00$", "format": "{xx_in_xx00} honderd"},
|
||||
"4": {"match": "^\\d{2}00$", "format": "{x_in_x00} en {x0_in_x000} honderd"},
|
||||
"5": {"match": "^\\d0\\d\\d$", "format": "{x_in_x000} duizend"},
|
||||
"6": {"match": "^1\\d{3}$", "format": "{xx_in_xx00}"},
|
||||
"7": {"match": "^\\d{4}$", "format": "{x_in_0x00} en {x0_in_x000}"},
|
||||
"default": "{number}"
|
||||
},
|
||||
"year_format": {
|
||||
"1": {"match": "^\\d{1}?$", "format": "{formatted_decade} {bc}"},
|
||||
"2": {"match": "^\\d{2}?$", "format": "{formatted_decade} {bc}"},
|
||||
"3": {"match": "^\\d00$", "format": "{formatted_hundreds} {bc}"},
|
||||
"4": {"match": "^\\d{3}$", "format": "{formatted_hundreds} {formatted_decade} {bc}"},
|
||||
"5": {"match": "^\\d{2}00$", "format": "{formatted_thousand} {bc}"},
|
||||
"6": {"match": "^\\d00\\d$", "format": "{formatted_thousand} {formatted_decade} {bc}"},
|
||||
"7": {"match": "^\\d{2}0\\d$", "format": "{formatted_thousand} {formatted_decade} {bc}"},
|
||||
"8": {"match": "^\\d{4}$", "format": "{formatted_thousand} {formatted_decade} {bc}"},
|
||||
"default": "{year} {bc}",
|
||||
"bc": "v.c."
|
||||
},
|
||||
"date_format": {
|
||||
"date_full": "{weekday}, {day} {month}, {formatted_year}",
|
||||
"date_full_no_year": "{weekday}, {day} {month}",
|
||||
"date_full_no_year_month": "{weekday}, {day} {month}",
|
||||
"today": "vandaag",
|
||||
"tomorrow": "morgen",
|
||||
"yesterday": "gisteren"
|
||||
},
|
||||
"time_format": {
|
||||
"time_full": "{minutes} over {hour}"
|
||||
},
|
||||
"date_time_format": {
|
||||
"date_time": "{formatted_date} om {formatted_time}"
|
||||
},
|
||||
"weekday": {
|
||||
"0": "maandag",
|
||||
"1": "dinsdag",
|
||||
"2": "woensdag",
|
||||
"3": "donderdag",
|
||||
"4": "vrijdag",
|
||||
"5": "zaterdag",
|
||||
"6": "zondag"
|
||||
},
|
||||
"date": {
|
||||
"1": "een",
|
||||
"2": "twee",
|
||||
"3": "drie",
|
||||
"4": "vier",
|
||||
"5": "vijf",
|
||||
"6": "zes",
|
||||
"7": "zeven",
|
||||
"8": "acht",
|
||||
"9": "negen",
|
||||
"10": "tien",
|
||||
"11": "elf",
|
||||
"12": "twaalf",
|
||||
"13": "dertien",
|
||||
"14": "veertien",
|
||||
"15": "vijtien",
|
||||
"16": "zestien",
|
||||
"17": "zeventien",
|
||||
"18": "achttien",
|
||||
"19": "negentien",
|
||||
"20": "twintig",
|
||||
"21": "eenentwintig",
|
||||
"22": "tweeentwintig",
|
||||
"23": "drieentwintig",
|
||||
"24": "vierentwintig",
|
||||
"25": "vijfentwintig",
|
||||
"26": "zesentwintig",
|
||||
"27": "zevenentwintig",
|
||||
"28": "achtentwintig",
|
||||
"29": "negenentwintig",
|
||||
"30": "dertig",
|
||||
"31": "eenendertig"
|
||||
},
|
||||
"month": {
|
||||
"1": "januari",
|
||||
"2": "februari",
|
||||
"3": "maart",
|
||||
"4": "april",
|
||||
"5": "mei",
|
||||
"6": "juni",
|
||||
"7": "juli",
|
||||
"8": "augustus",
|
||||
"9": "september",
|
||||
"10": "oktober",
|
||||
"11": "november",
|
||||
"12": "december"
|
||||
},
|
||||
"number": {
|
||||
"0": "nul",
|
||||
"1": "een",
|
||||
"2": "twee",
|
||||
"3": "drie",
|
||||
"4": "vier",
|
||||
"5": "vijf",
|
||||
"6": "zes",
|
||||
"7": "zeven",
|
||||
"8": "acht",
|
||||
"9": "negen",
|
||||
"10": "tien",
|
||||
"11": "elf",
|
||||
"12": "twaalf",
|
||||
"13": "dertien",
|
||||
"14": "veertien",
|
||||
"15": "vijtien",
|
||||
"16": "zestien",
|
||||
"17": "zeventien",
|
||||
"18": "achttien",
|
||||
"19": "negentien",
|
||||
"20": "twintig",
|
||||
"30": "dertig",
|
||||
"40": "veertig",
|
||||
"50": "vijftig",
|
||||
"60": "zestig",
|
||||
"70": "zeventig",
|
||||
"80": "tachtig",
|
||||
"90": "negentig"
|
||||
}
|
||||
}
|
|
@ -1,131 +0,0 @@
|
|||
{
|
||||
"decade_format": {
|
||||
"1": {"match": "^1$", "format": "ett"},
|
||||
"2": {"match": "^\\d$", "format": "{x}"},
|
||||
"3": {"match": "^\\d\\d$", "format": "{xx}"},
|
||||
"4": {"match": "^\\d0$", "format": "{x0}"},
|
||||
"default": "{number}"
|
||||
},
|
||||
"hundreds_format": {
|
||||
"1": {"match": "^1\\d{2}$", "format": "ett hundra"},
|
||||
"2": {"match": "^\\d{3}$", "format": "{x_in_x00} hundra"},
|
||||
"default": "{number}"
|
||||
},
|
||||
"thousand_format": {
|
||||
"1": {"match": "^1[1-9]\\d{2}$", "format": "{xx_in_xx00} hundra"},
|
||||
"2": {"match": "^1\\d{3}$", "format": "ett tusen"},
|
||||
"3": {"match": "^\\d{4}$", "format": "{x_in_x000} tusen"},
|
||||
"default": "{number}"
|
||||
},
|
||||
"year_format": {
|
||||
"1": {"match": "^\\d\\d?$", "format": "{formatted_decade} {bc}"},
|
||||
"2": {"match": "^\\d00$", "format": "{formatted_hundreds} {bc}"},
|
||||
"3": {"match": "^\\d{3}$", "format": "{formatted_hundreds} {formatted_decade} {bc}"},
|
||||
"4": {"match": "^(1\\d00)|([2-9]000)$", "format": "{formatted_thousand} {bc}"},
|
||||
"5": {"match": "^(1\\d{3})|(\\d0\\d{2})$", "format": "{formatted_thousand} {formatted_decade} {bc}"},
|
||||
"6": {"match": "^\\d{4}$", "format": "{formatted_thousand} {formatted_hundreds} {formatted_decade} {bc}"},
|
||||
"default": "{year} {bc}",
|
||||
"bc": "f.kr."
|
||||
},
|
||||
"date_format": {
|
||||
"date_full": "{weekday}, den {day} {month}, {formatted_year}",
|
||||
"date_full_no_year": "{weekday}, den {day} {month}",
|
||||
"date_full_no_year_month": "{weekday}, den {day}",
|
||||
"today": "i dag",
|
||||
"tomorrow": "i morgon",
|
||||
"yesterday": "i går"
|
||||
},
|
||||
"date_time_format": {
|
||||
"date_time": "{formatted_date} klockan {formatted_time}"
|
||||
},
|
||||
"weekday": {
|
||||
"0": "måndag",
|
||||
"1": "tisdag",
|
||||
"2": "onsdag",
|
||||
"3": "torsdag",
|
||||
"4": "fredag",
|
||||
"5": "lördag",
|
||||
"6": "söndag"
|
||||
},
|
||||
"date": {
|
||||
"1": "förste",
|
||||
"2": "andra",
|
||||
"3": "tredje",
|
||||
"4": "fjärde",
|
||||
"5": "femte",
|
||||
"6": "sjätte",
|
||||
"7": "sjunde",
|
||||
"8": "åttonde",
|
||||
"9": "nionde",
|
||||
"10": "tionde",
|
||||
"11": "elfte",
|
||||
"12": "tolfte",
|
||||
"13": "trettionde",
|
||||
"14": "fjortonde",
|
||||
"15": "femtonde",
|
||||
"16": "sextonde",
|
||||
"17": "sjuttonde",
|
||||
"18": "artonde",
|
||||
"19": "nittonde",
|
||||
"20": "tjugonde",
|
||||
"21": "tjugoförste",
|
||||
"22": "tjugoandre",
|
||||
"23": "tjugotredje",
|
||||
"24": "tjugofjärde",
|
||||
"25": "tjugofemte",
|
||||
"26": "tjugosjätte",
|
||||
"27": "tjugosjunde",
|
||||
"28": "tjugoåttonde",
|
||||
"29": "tjugonionde",
|
||||
"30": "trettionde",
|
||||
"31": "trettioförste"
|
||||
},
|
||||
"month": {
|
||||
"1": "januari",
|
||||
"2": "februari",
|
||||
"3": "mars",
|
||||
"4": "april",
|
||||
"5": "maj",
|
||||
"6": "juni",
|
||||
"7": "juli",
|
||||
"8": "augusti",
|
||||
"9": "september",
|
||||
"10": "oktober",
|
||||
"11": "november",
|
||||
"12": "december"
|
||||
},
|
||||
"number": {
|
||||
"0": "noll",
|
||||
"1": "en",
|
||||
"2": "två",
|
||||
"3": "tre",
|
||||
"4": "fyra",
|
||||
"5": "fem",
|
||||
"6": "sex",
|
||||
"7": "sju",
|
||||
"8": "åtta",
|
||||
"9": "nio",
|
||||
"10": "tio",
|
||||
"11": "elva",
|
||||
"12": "tolv",
|
||||
"13": "tretton",
|
||||
"14": "fjorton",
|
||||
"15": "femton",
|
||||
"16": "sexton",
|
||||
"17": "sjutton",
|
||||
"18": "arton",
|
||||
"19": "nitton",
|
||||
"20": "tjugo",
|
||||
"30": "trettio",
|
||||
"40": "fyrtio",
|
||||
"50": "femtio",
|
||||
"60": "sextio",
|
||||
"70": "sjuttio",
|
||||
"80": "åttio",
|
||||
"90": "nitio",
|
||||
"100": "hundra",
|
||||
"1000": "tusen",
|
||||
"2000": "tvåtusen"
|
||||
}
|
||||
|
||||
}
|
|
@ -20,79 +20,38 @@ things like numbers, times, etc.
|
|||
The focus of these formatting functions is to create natural sounding speech
|
||||
and allow localization.
|
||||
"""
|
||||
import json
|
||||
import os
|
||||
import datetime
|
||||
import re
|
||||
import warnings
|
||||
|
||||
from collections import namedtuple
|
||||
from calendar import leapdays
|
||||
from enum import Enum
|
||||
|
||||
from mycroft.util.lang import get_full_lang_code, get_primary_lang_code
|
||||
from lingua_franca.format import (NUMBER_TUPLE, DateTimeFormat, join_list,
|
||||
date_time_format, expand_options,
|
||||
_translate_word)
|
||||
|
||||
from mycroft.util.lang.format_en import *
|
||||
from mycroft.util.lang.format_pt import *
|
||||
from mycroft.util.lang.format_it import *
|
||||
from mycroft.util.lang.format_sv import *
|
||||
from mycroft.util.lang.format_hu import *
|
||||
from lingua_franca.lang import get_full_lang_code, get_primary_lang_code
|
||||
|
||||
from mycroft.util.lang.format_es import nice_number_es
|
||||
from mycroft.util.lang.format_es import nice_time_es
|
||||
from mycroft.util.lang.format_es import pronounce_number_es
|
||||
from mycroft.util.lang.format_de import nice_number_de
|
||||
from mycroft.util.lang.format_de import nice_time_de
|
||||
from mycroft.util.lang.format_de import pronounce_number_de
|
||||
from mycroft.util.lang.format_fr import nice_number_fr
|
||||
from mycroft.util.lang.format_fr import nice_time_fr
|
||||
from mycroft.util.lang.format_fr import pronounce_number_fr
|
||||
from mycroft.util.lang.format_nl import nice_time_nl
|
||||
from mycroft.util.lang.format_nl import pronounce_number_nl
|
||||
from mycroft.util.lang.format_nl import nice_number_nl
|
||||
from mycroft.util.lang.format_da import nice_number_da
|
||||
from mycroft.util.lang.format_da import nice_time_da
|
||||
from mycroft.util.lang.format_da import pronounce_number_da
|
||||
from lingua_franca.lang.format_en import *
|
||||
from lingua_franca.lang.format_pt import *
|
||||
from lingua_franca.lang.format_it import *
|
||||
from lingua_franca.lang.format_sv import *
|
||||
from lingua_franca.lang.format_hu import *
|
||||
|
||||
from lingua_franca.lang.format_es import (nice_number_es, nice_time_es,
|
||||
pronounce_number_es)
|
||||
from lingua_franca.lang.format_de import (nice_number_de, nice_time_de,
|
||||
pronounce_number_de)
|
||||
from lingua_franca.lang.format_fr import (nice_number_fr, nice_time_fr,
|
||||
pronounce_number_fr)
|
||||
from lingua_franca.lang.format_nl import (nice_time_nl, pronounce_number_nl,
|
||||
nice_number_nl)
|
||||
from lingua_franca.lang.format_da import (nice_number_da, nice_time_da,
|
||||
pronounce_number_da)
|
||||
|
||||
from padatious.util import expand_parentheses
|
||||
|
||||
|
||||
def _translate_word(name, lang):
|
||||
""" Helper to get word tranlations
|
||||
|
||||
Args:
|
||||
name (str): Word name. Returned as the default value if not translated.
|
||||
lang (str): Language code, e.g. "en-us"
|
||||
|
||||
Returns:
|
||||
str: translated version of resource name
|
||||
"""
|
||||
from mycroft.util import resolve_resource_file
|
||||
|
||||
lang_code = get_full_lang_code(lang)
|
||||
|
||||
filename = resolve_resource_file(
|
||||
os.path.join("text", lang_code, name+".word"))
|
||||
if filename:
|
||||
# open the file
|
||||
try:
|
||||
with open(filename, 'r', encoding='utf8') as f:
|
||||
for line in f:
|
||||
word = line.strip()
|
||||
if word.startswith("#"):
|
||||
continue # skip comment lines
|
||||
return word
|
||||
except Exception:
|
||||
pass
|
||||
return name # use resource name as the word
|
||||
|
||||
|
||||
NUMBER_TUPLE = namedtuple(
|
||||
'number',
|
||||
('x, xx, x0, x_in_x0, xxx, x00, x_in_x00, xx00, xx_in_xx00, x000, ' +
|
||||
'x_in_x000, x0_in_x000, x_in_0x00'))
|
||||
|
||||
|
||||
class TimeResolution(Enum):
|
||||
YEARS = 1
|
||||
DAYS = 2
|
||||
|
@ -102,167 +61,6 @@ class TimeResolution(Enum):
|
|||
MILLISECONDS = 6
|
||||
|
||||
|
||||
class DateTimeFormat:
|
||||
def __init__(self, config_path):
|
||||
self.lang_config = {}
|
||||
self.config_path = config_path
|
||||
|
||||
def cache(self, lang):
|
||||
if lang not in self.lang_config:
|
||||
try:
|
||||
# Attempt to load the language-specific formatting data
|
||||
with open(self.config_path + '/' + lang + '/date_time.json',
|
||||
'r') as lang_config_file:
|
||||
self.lang_config[lang] = json.loads(
|
||||
lang_config_file.read())
|
||||
except FileNotFoundError:
|
||||
# Fallback to English formatting
|
||||
with open(self.config_path + '/en-us/date_time.json',
|
||||
'r') as lang_config_file:
|
||||
self.lang_config[lang] = json.loads(
|
||||
lang_config_file.read())
|
||||
|
||||
for x in ['decade_format', 'hundreds_format', 'thousand_format',
|
||||
'year_format']:
|
||||
i = 1
|
||||
while self.lang_config[lang][x].get(str(i)):
|
||||
self.lang_config[lang][x][str(i)]['re'] = (
|
||||
re.compile(self.lang_config[lang][x][str(i)]['match']
|
||||
))
|
||||
i = i + 1
|
||||
|
||||
def _number_strings(self, number, lang):
|
||||
x = (self.lang_config[lang]['number'].get(str(number % 10)) or
|
||||
str(number % 10))
|
||||
xx = (self.lang_config[lang]['number'].get(str(number % 100)) or
|
||||
str(number % 100))
|
||||
x_in_x0 = self.lang_config[lang]['number'].get(
|
||||
str(int(number % 100 / 10))) or str(int(number % 100 / 10))
|
||||
x0 = (self.lang_config[lang]['number'].get(
|
||||
str(int(number % 100 / 10) * 10)) or
|
||||
str(int(number % 100 / 10) * 10))
|
||||
xxx = (self.lang_config[lang]['number'].get(str(number % 1000)) or
|
||||
str(number % 1000))
|
||||
x00 = (self.lang_config[lang]['number'].get(str(int(
|
||||
number % 1000 / 100) * 100)) or
|
||||
str(int(number % 1000 / 100) * 100))
|
||||
x_in_x00 = self.lang_config[lang]['number'].get(str(int(
|
||||
number % 1000 / 100))) or str(int(number % 1000 / 100))
|
||||
xx00 = self.lang_config[lang]['number'].get(str(int(
|
||||
number % 10000 / 100) * 100)) or str(int(number % 10000 / 100) *
|
||||
100)
|
||||
xx_in_xx00 = self.lang_config[lang]['number'].get(str(int(
|
||||
number % 10000 / 100))) or str(int(number % 10000 / 100))
|
||||
x000 = (self.lang_config[lang]['number'].get(str(int(
|
||||
number % 10000 / 1000) * 1000)) or
|
||||
str(int(number % 10000 / 1000) * 1000))
|
||||
x_in_x000 = self.lang_config[lang]['number'].get(str(int(
|
||||
number % 10000 / 1000))) or str(int(number % 10000 / 1000))
|
||||
x0_in_x000 = self.lang_config[lang]['number'].get(str(int(
|
||||
number % 10000 / 1000)*10)) or str(int(number % 10000 / 1000)*10)
|
||||
x_in_0x00 = self.lang_config[lang]['number'].get(str(int(
|
||||
number % 1000 / 100)) or str(int(number % 1000 / 100)))
|
||||
|
||||
return NUMBER_TUPLE(
|
||||
x, xx, x0, x_in_x0, xxx, x00, x_in_x00, xx00, xx_in_xx00, x000,
|
||||
x_in_x000, x0_in_x000, x_in_0x00)
|
||||
|
||||
def _format_string(self, number, format_section, lang):
|
||||
s = self.lang_config[lang][format_section]['default']
|
||||
i = 1
|
||||
while self.lang_config[lang][format_section].get(str(i)):
|
||||
e = self.lang_config[lang][format_section][str(i)]
|
||||
if e['re'].match(str(number)):
|
||||
return e['format']
|
||||
i = i + 1
|
||||
return s
|
||||
|
||||
def _decade_format(self, number, number_tuple, lang):
|
||||
s = self._format_string(number % 100, 'decade_format', lang)
|
||||
return s.format(x=number_tuple.x, xx=number_tuple.xx,
|
||||
x0=number_tuple.x0, x_in_x0=number_tuple.x_in_x0,
|
||||
number=str(number % 100))
|
||||
|
||||
def _number_format_hundreds(self, number, number_tuple, lang,
|
||||
formatted_decade):
|
||||
s = self._format_string(number % 1000, 'hundreds_format', lang)
|
||||
return s.format(xxx=number_tuple.xxx, x00=number_tuple.x00,
|
||||
x_in_x00=number_tuple.x_in_x00,
|
||||
formatted_decade=formatted_decade,
|
||||
number=str(number % 1000))
|
||||
|
||||
def _number_format_thousand(self, number, number_tuple, lang,
|
||||
formatted_decade, formatted_hundreds):
|
||||
s = self._format_string(number % 10000, 'thousand_format', lang)
|
||||
return s.format(x_in_x00=number_tuple.x_in_x00,
|
||||
xx00=number_tuple.xx00,
|
||||
xx_in_xx00=number_tuple.xx_in_xx00,
|
||||
x000=number_tuple.x000,
|
||||
x_in_x000=number_tuple.x_in_x000,
|
||||
x0_in_x000=number_tuple.x0_in_x000,
|
||||
x_in_0x00=number_tuple.x_in_0x00,
|
||||
formatted_decade=formatted_decade,
|
||||
formatted_hundreds=formatted_hundreds,
|
||||
number=str(number % 10000))
|
||||
|
||||
def date_format(self, dt, lang, now):
|
||||
format_str = 'date_full'
|
||||
if now:
|
||||
if dt.year == now.year:
|
||||
format_str = 'date_full_no_year'
|
||||
if dt.month == now.month and dt.day > now.day:
|
||||
format_str = 'date_full_no_year_month'
|
||||
|
||||
tomorrow = now + datetime.timedelta(days=1)
|
||||
yesterday = now - datetime.timedelta(days=1)
|
||||
if tomorrow.date() == dt.date():
|
||||
format_str = 'tomorrow'
|
||||
elif now.date() == dt.date():
|
||||
format_str = 'today'
|
||||
elif yesterday.date() == dt.date():
|
||||
format_str = 'yesterday'
|
||||
|
||||
return self.lang_config[lang]['date_format'][format_str].format(
|
||||
weekday=self.lang_config[lang]['weekday'][str(dt.weekday())],
|
||||
month=self.lang_config[lang]['month'][str(dt.month)],
|
||||
day=self.lang_config[lang]['date'][str(dt.day)],
|
||||
formatted_year=self.year_format(dt, lang, False))
|
||||
|
||||
def date_time_format(self, dt, lang, now, use_24hour, use_ampm):
|
||||
date_str = self.date_format(dt, lang, now)
|
||||
time_str = nice_time(dt, lang, use_24hour=use_24hour,
|
||||
use_ampm=use_ampm)
|
||||
return self.lang_config[lang]['date_time_format']['date_time'].format(
|
||||
formatted_date=date_str, formatted_time=time_str)
|
||||
|
||||
def year_format(self, dt, lang, bc):
|
||||
number_tuple = self._number_strings(dt.year, lang)
|
||||
formatted_bc = (
|
||||
self.lang_config[lang]['year_format']['bc'] if bc else '')
|
||||
formatted_decade = self._decade_format(
|
||||
dt.year, number_tuple, lang)
|
||||
formatted_hundreds = self._number_format_hundreds(
|
||||
dt.year, number_tuple, lang, formatted_decade)
|
||||
formatted_thousand = self._number_format_thousand(
|
||||
dt.year, number_tuple, lang, formatted_decade, formatted_hundreds)
|
||||
|
||||
s = self._format_string(dt.year, 'year_format', lang)
|
||||
|
||||
return re.sub(' +', ' ',
|
||||
s.format(
|
||||
year=str(dt.year),
|
||||
century=str(int(dt.year / 100)),
|
||||
decade=str(dt.year % 100),
|
||||
formatted_hundreds=formatted_hundreds,
|
||||
formatted_decade=formatted_decade,
|
||||
formatted_thousand=formatted_thousand,
|
||||
bc=formatted_bc)).strip()
|
||||
|
||||
|
||||
date_time_format = DateTimeFormat(
|
||||
os.path.dirname(os.path.abspath(__file__)) + '/../res/text')
|
||||
|
||||
|
||||
def nice_number(number, lang=None, speech=True, denominators=None):
|
||||
"""Format a float to human readable functions
|
||||
|
||||
|
@ -798,45 +596,3 @@ def nice_duration_dt(date1, date2, lang=None, speech=True, use_years=True,
|
|||
return _duration_handler(big, lang=lang, speech=speech, time2=small,
|
||||
use_years=use_years, resolution=resolution,
|
||||
clock=clock)
|
||||
|
||||
|
||||
def join_list(items, connector, sep=None, lang=None):
|
||||
""" Join a list into a phrase using the given connector word
|
||||
|
||||
Examples:
|
||||
join_list([1,2,3], "and") -> "1, 2 and 3"
|
||||
join_list([1,2,3], "and", ";") -> "1; 2 and 3"
|
||||
|
||||
Args:
|
||||
items(array): items to be joined
|
||||
connector(str): connecting word (resource name), like "and" or "or"
|
||||
sep(str, optional): separator character, default = ","
|
||||
Returns:
|
||||
str: the connected list phrase
|
||||
"""
|
||||
|
||||
if not items:
|
||||
return ""
|
||||
if len(items) == 1:
|
||||
return str(items[0])
|
||||
|
||||
if not sep:
|
||||
sep = ", "
|
||||
else:
|
||||
sep += " "
|
||||
return (sep.join(str(item) for item in items[:-1]) +
|
||||
" " + _translate_word(connector, lang) +
|
||||
" " + items[-1])
|
||||
|
||||
|
||||
def expand_options(parentheses_line: str) -> list:
|
||||
"""
|
||||
Convert 'test (a|b)' -> ['test a', 'test b']
|
||||
Args:
|
||||
parentheses_line: Input line to expand
|
||||
Returns:
|
||||
List of expanded possibilities
|
||||
"""
|
||||
# 'a(this|that)b' -> [['a', 'this', 'b'], ['a', 'that', 'b']]
|
||||
options = expand_parentheses(re.split(r'([(|)])', parentheses_line))
|
||||
return [re.sub(r'\s+', ' ', ' '.join(i)).strip() for i in options]
|
||||
|
|
|
@ -13,58 +13,5 @@
|
|||
# limitations under the License.
|
||||
#
|
||||
|
||||
__active_lang = "en-us" # English is the default active language
|
||||
# TODO: Should this really be stored in the user config file?
|
||||
|
||||
|
||||
def get_active_lang():
|
||||
""" Get the active full language code (BCP-47)
|
||||
|
||||
Returns:
|
||||
str: A BCP-47 language code, e.g. ("en-us", or "pt-pt")
|
||||
"""
|
||||
return __active_lang
|
||||
|
||||
|
||||
def set_active_lang(lang_code):
|
||||
""" Set the active BCP-47 language code to be used in formatting/parsing
|
||||
|
||||
Args:
|
||||
lang (str): BCP-47 language code, e.g. "en-us" or "es-mx"
|
||||
"""
|
||||
global __active_lang
|
||||
if __active_lang != lang_code:
|
||||
# TODO: Validate lang codes?
|
||||
__active_lang = lang_code
|
||||
|
||||
|
||||
def get_primary_lang_code(lang=None):
|
||||
""" Get the primary language code
|
||||
|
||||
Args:
|
||||
lang (str, optional): A BCP-47 language code, or None for default
|
||||
|
||||
Returns:
|
||||
str: A primary language family, such as "en", "de" or "pt"
|
||||
"""
|
||||
# split on the hyphen and only return the primary-language code
|
||||
# NOTE: This is typically a two character code. The standard allows
|
||||
# 1, 2, 3 and 4 character codes. In the future we can consider
|
||||
# mapping from the 3 to 2 character codes, for example. But for
|
||||
# now we can just be careful in use.
|
||||
return get_full_lang_code(lang).split("-")[0]
|
||||
|
||||
|
||||
def get_full_lang_code(lang=None):
|
||||
""" Get the full language code
|
||||
|
||||
Args:
|
||||
lang (str, optional): A BCP-47 language code, or None for default
|
||||
|
||||
Returns:
|
||||
str: A full language code, such as "en-us" or "de-de"
|
||||
"""
|
||||
if not lang:
|
||||
lang = __active_lang
|
||||
|
||||
return lang or "en-us"
|
||||
from lingua_franca.lang import (get_active_lang, set_active_lang,
|
||||
get_primary_lang_code, get_full_lang_code)
|
||||
|
|
|
@ -1,244 +0,0 @@
|
|||
#
|
||||
# Copyright 2017 Mycroft AI Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
from collections import OrderedDict
|
||||
|
||||
|
||||
_ARTICLES = {'a', 'an', 'the'}
|
||||
|
||||
|
||||
_NUM_STRING_EN = {
|
||||
0: 'zero',
|
||||
1: 'one',
|
||||
2: 'two',
|
||||
3: 'three',
|
||||
4: 'four',
|
||||
5: 'five',
|
||||
6: 'six',
|
||||
7: 'seven',
|
||||
8: 'eight',
|
||||
9: 'nine',
|
||||
10: 'ten',
|
||||
11: 'eleven',
|
||||
12: 'twelve',
|
||||
13: 'thirteen',
|
||||
14: 'fourteen',
|
||||
15: 'fifteen',
|
||||
16: 'sixteen',
|
||||
17: 'seventeen',
|
||||
18: 'eighteen',
|
||||
19: 'nineteen',
|
||||
20: 'twenty',
|
||||
30: 'thirty',
|
||||
40: 'forty',
|
||||
50: 'fifty',
|
||||
60: 'sixty',
|
||||
70: 'seventy',
|
||||
80: 'eighty',
|
||||
90: 'ninety'
|
||||
}
|
||||
|
||||
|
||||
_FRACTION_STRING_EN = {
|
||||
2: 'half',
|
||||
3: 'third',
|
||||
4: 'forth',
|
||||
5: 'fifth',
|
||||
6: 'sixth',
|
||||
7: 'seventh',
|
||||
8: 'eigth',
|
||||
9: 'ninth',
|
||||
10: 'tenth',
|
||||
11: 'eleventh',
|
||||
12: 'twelveth',
|
||||
13: 'thirteenth',
|
||||
14: 'fourteenth',
|
||||
15: 'fifteenth',
|
||||
16: 'sixteenth',
|
||||
17: 'seventeenth',
|
||||
18: 'eighteenth',
|
||||
19: 'nineteenth',
|
||||
20: 'twentyith'
|
||||
}
|
||||
|
||||
|
||||
_LONG_SCALE_EN = OrderedDict([
|
||||
(100, 'hundred'),
|
||||
(1000, 'thousand'),
|
||||
(1000000, 'million'),
|
||||
(1e12, "billion"),
|
||||
(1e18, 'trillion'),
|
||||
(1e24, "quadrillion"),
|
||||
(1e30, "quintillion"),
|
||||
(1e36, "sextillion"),
|
||||
(1e42, "septillion"),
|
||||
(1e48, "octillion"),
|
||||
(1e54, "nonillion"),
|
||||
(1e60, "decillion"),
|
||||
(1e66, "undecillion"),
|
||||
(1e72, "duodecillion"),
|
||||
(1e78, "tredecillion"),
|
||||
(1e84, "quattuordecillion"),
|
||||
(1e90, "quinquadecillion"),
|
||||
(1e96, "sedecillion"),
|
||||
(1e102, "septendecillion"),
|
||||
(1e108, "octodecillion"),
|
||||
(1e114, "novendecillion"),
|
||||
(1e120, "vigintillion"),
|
||||
(1e306, "unquinquagintillion"),
|
||||
(1e312, "duoquinquagintillion"),
|
||||
(1e336, "sesquinquagintillion"),
|
||||
(1e366, "unsexagintillion")
|
||||
])
|
||||
|
||||
|
||||
_SHORT_SCALE_EN = OrderedDict([
|
||||
(100, 'hundred'),
|
||||
(1000, 'thousand'),
|
||||
(1000000, 'million'),
|
||||
(1e9, "billion"),
|
||||
(1e12, 'trillion'),
|
||||
(1e15, "quadrillion"),
|
||||
(1e18, "quintillion"),
|
||||
(1e21, "sextillion"),
|
||||
(1e24, "septillion"),
|
||||
(1e27, "octillion"),
|
||||
(1e30, "nonillion"),
|
||||
(1e33, "decillion"),
|
||||
(1e36, "undecillion"),
|
||||
(1e39, "duodecillion"),
|
||||
(1e42, "tredecillion"),
|
||||
(1e45, "quattuordecillion"),
|
||||
(1e48, "quinquadecillion"),
|
||||
(1e51, "sedecillion"),
|
||||
(1e54, "septendecillion"),
|
||||
(1e57, "octodecillion"),
|
||||
(1e60, "novendecillion"),
|
||||
(1e63, "vigintillion"),
|
||||
(1e66, "unvigintillion"),
|
||||
(1e69, "uuovigintillion"),
|
||||
(1e72, "tresvigintillion"),
|
||||
(1e75, "quattuorvigintillion"),
|
||||
(1e78, "quinquavigintillion"),
|
||||
(1e81, "qesvigintillion"),
|
||||
(1e84, "septemvigintillion"),
|
||||
(1e87, "octovigintillion"),
|
||||
(1e90, "novemvigintillion"),
|
||||
(1e93, "trigintillion"),
|
||||
(1e96, "untrigintillion"),
|
||||
(1e99, "duotrigintillion"),
|
||||
(1e102, "trestrigintillion"),
|
||||
(1e105, "quattuortrigintillion"),
|
||||
(1e108, "quinquatrigintillion"),
|
||||
(1e111, "sestrigintillion"),
|
||||
(1e114, "septentrigintillion"),
|
||||
(1e117, "octotrigintillion"),
|
||||
(1e120, "noventrigintillion"),
|
||||
(1e123, "quadragintillion"),
|
||||
(1e153, "quinquagintillion"),
|
||||
(1e183, "sexagintillion"),
|
||||
(1e213, "septuagintillion"),
|
||||
(1e243, "octogintillion"),
|
||||
(1e273, "nonagintillion"),
|
||||
(1e303, "centillion"),
|
||||
(1e306, "uncentillion"),
|
||||
(1e309, "duocentillion"),
|
||||
(1e312, "trescentillion"),
|
||||
(1e333, "decicentillion"),
|
||||
(1e336, "undecicentillion"),
|
||||
(1e363, "viginticentillion"),
|
||||
(1e366, "unviginticentillion"),
|
||||
(1e393, "trigintacentillion"),
|
||||
(1e423, "quadragintacentillion"),
|
||||
(1e453, "quinquagintacentillion"),
|
||||
(1e483, "sexagintacentillion"),
|
||||
(1e513, "septuagintacentillion"),
|
||||
(1e543, "ctogintacentillion"),
|
||||
(1e573, "nonagintacentillion"),
|
||||
(1e603, "ducentillion"),
|
||||
(1e903, "trecentillion"),
|
||||
(1e1203, "quadringentillion"),
|
||||
(1e1503, "quingentillion"),
|
||||
(1e1803, "sescentillion"),
|
||||
(1e2103, "septingentillion"),
|
||||
(1e2403, "octingentillion"),
|
||||
(1e2703, "nongentillion"),
|
||||
(1e3003, "millinillion")
|
||||
])
|
||||
|
||||
|
||||
_ORDINAL_STRING_BASE_EN = {
|
||||
1: 'first',
|
||||
2: 'second',
|
||||
3: 'third',
|
||||
4: 'fourth',
|
||||
5: 'fifth',
|
||||
6: 'sixth',
|
||||
7: 'seventh',
|
||||
8: 'eighth',
|
||||
9: 'ninth',
|
||||
10: 'tenth',
|
||||
11: 'eleventh',
|
||||
12: 'twelfth',
|
||||
13: 'thirteenth',
|
||||
14: 'fourteenth',
|
||||
15: 'fifteenth',
|
||||
16: 'sixteenth',
|
||||
17: 'seventeenth',
|
||||
18: 'eighteenth',
|
||||
19: 'nineteenth',
|
||||
20: 'twentieth',
|
||||
30: 'thirtieth',
|
||||
40: "fortieth",
|
||||
50: "fiftieth",
|
||||
60: "sixtieth",
|
||||
70: "seventieth",
|
||||
80: "eightieth",
|
||||
90: "ninetieth",
|
||||
10e3: "hundredth",
|
||||
1e3: "thousandth"
|
||||
}
|
||||
|
||||
|
||||
_SHORT_ORDINAL_STRING_EN = {
|
||||
1e6: "millionth",
|
||||
1e9: "billionth",
|
||||
1e12: "trillionth",
|
||||
1e15: "quadrillionth",
|
||||
1e18: "quintillionth",
|
||||
1e21: "sextillionth",
|
||||
1e24: "septillionth",
|
||||
1e27: "octillionth",
|
||||
1e30: "nonillionth",
|
||||
1e33: "decillionth"
|
||||
# TODO > 1e-33
|
||||
}
|
||||
_SHORT_ORDINAL_STRING_EN.update(_ORDINAL_STRING_BASE_EN)
|
||||
|
||||
|
||||
_LONG_ORDINAL_STRING_EN = {
|
||||
1e6: "millionth",
|
||||
1e12: "billionth",
|
||||
1e18: "trillionth",
|
||||
1e24: "quadrillionth",
|
||||
1e30: "quintillionth",
|
||||
1e36: "sextillionth",
|
||||
1e42: "septillionth",
|
||||
1e48: "octillionth",
|
||||
1e54: "nonillionth",
|
||||
1e60: "decillionth"
|
||||
# TODO > 1e60
|
||||
}
|
||||
_LONG_ORDINAL_STRING_EN.update(_ORDINAL_STRING_BASE_EN)
|
|
@ -1,248 +0,0 @@
|
|||
#
|
||||
# Copyright 2017 Mycroft AI Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
# NOTE: This file as no use yet. It needs to be called from other functions
|
||||
|
||||
from collections import OrderedDict
|
||||
|
||||
|
||||
_ARTICLES = {'el', 'la', 'los', 'las'}
|
||||
|
||||
|
||||
NUM_STRING_ES = {
|
||||
0: 'cero',
|
||||
1: 'uno',
|
||||
2: 'dos',
|
||||
3: 'tres',
|
||||
4: 'cuatro',
|
||||
5: 'cinco',
|
||||
6: 'seis',
|
||||
7: 'siete',
|
||||
8: 'ocho',
|
||||
9: 'nueve',
|
||||
10: 'diez',
|
||||
11: 'once',
|
||||
12: 'doce',
|
||||
13: 'trece',
|
||||
14: 'catorce',
|
||||
15: 'quince',
|
||||
16: 'dieciséis',
|
||||
17: 'diecisete',
|
||||
18: 'dieciocho',
|
||||
19: 'diecinueve',
|
||||
20: 'veinte',
|
||||
30: 'treinta',
|
||||
40: 'cuarenta',
|
||||
50: 'cincuenta',
|
||||
60: 'sesenta',
|
||||
70: 'setenta',
|
||||
80: 'ochenta',
|
||||
90: 'noventa'
|
||||
}
|
||||
|
||||
|
||||
_FRACTION_STRING_ES = {
|
||||
2: 'medio',
|
||||
3: 'tercio',
|
||||
4: 'cuarto',
|
||||
5: 'quinto',
|
||||
6: 'sexto',
|
||||
7: 'séptimo',
|
||||
8: 'octavo',
|
||||
9: 'noveno',
|
||||
10: 'décimo',
|
||||
11: 'onceavo',
|
||||
12: 'doceavo',
|
||||
13: 'treceavo',
|
||||
14: 'catorceavo',
|
||||
15: 'quinceavo',
|
||||
16: 'dieciseisavo',
|
||||
17: 'diecisieteavo',
|
||||
18: 'dieciochoavo',
|
||||
19: 'diecinueveavo',
|
||||
20: 'veinteavo'
|
||||
}
|
||||
|
||||
# https://www.grobauer.at/es_eur/zahlnamen.php
|
||||
_LONG_SCALE_ES = OrderedDict([
|
||||
(100, 'centena'),
|
||||
(1000, 'millar'),
|
||||
(1000000, 'millón'),
|
||||
(1e9, "millardo"),
|
||||
(1e12, "billón"),
|
||||
(1e18, 'trillón'),
|
||||
(1e24, "cuatrillón"),
|
||||
(1e30, "quintillón"),
|
||||
(1e36, "sextillón"),
|
||||
(1e42, "septillón"),
|
||||
(1e48, "octillón"),
|
||||
(1e54, "nonillón"),
|
||||
(1e60, "decillón"),
|
||||
(1e66, "undecillón"),
|
||||
(1e72, "duodecillón"),
|
||||
(1e78, "tredecillón"),
|
||||
(1e84, "cuatrodecillón"),
|
||||
(1e90, "quindecillón"),
|
||||
(1e96, "sexdecillón"),
|
||||
(1e102, "septendecillón"),
|
||||
(1e108, "octodecillón"),
|
||||
(1e114, "novendecillón"),
|
||||
(1e120, "vigintillón"),
|
||||
(1e306, "unquinquagintillón"),
|
||||
(1e312, "duoquinquagintillón"),
|
||||
(1e336, "sexquinquagintillón"),
|
||||
(1e366, "unsexagintillón")
|
||||
])
|
||||
|
||||
|
||||
_SHORT_SCALE_ES = OrderedDict([
|
||||
(100, 'centena'),
|
||||
(1000, 'millar'),
|
||||
(1000000, 'millón'),
|
||||
(1e9, "billón"),
|
||||
(1e12, 'trillón'),
|
||||
(1e15, "cuatrillón"),
|
||||
(1e18, "quintillón"),
|
||||
(1e21, "sextillón"),
|
||||
(1e24, "septillón"),
|
||||
(1e27, "octillón"),
|
||||
(1e30, "nonillón"),
|
||||
(1e33, "decillón"),
|
||||
(1e36, "undecillón"),
|
||||
(1e39, "duodecillón"),
|
||||
(1e42, "tredecillón"),
|
||||
(1e45, "cuatrodecillón"),
|
||||
(1e48, "quindecillón"),
|
||||
(1e51, "sexdecillón"),
|
||||
(1e54, "septendecillón"),
|
||||
(1e57, "octodecillón"),
|
||||
(1e60, "novendecillón"),
|
||||
(1e63, "vigintillón"),
|
||||
(1e66, "unvigintillón"),
|
||||
(1e69, "uuovigintillón"),
|
||||
(1e72, "tresvigintillón"),
|
||||
(1e75, "quattuorvigintillón"),
|
||||
(1e78, "quinquavigintillón"),
|
||||
(1e81, "qesvigintillón"),
|
||||
(1e84, "septemvigintillón"),
|
||||
(1e87, "octovigintillón"),
|
||||
(1e90, "novemvigintillón"),
|
||||
(1e93, "trigintillón"),
|
||||
(1e96, "untrigintillón"),
|
||||
(1e99, "duotrigintillón"),
|
||||
(1e102, "trestrigintillón"),
|
||||
(1e105, "quattuortrigintillón"),
|
||||
(1e108, "quinquatrigintillón"),
|
||||
(1e111, "sestrigintillón"),
|
||||
(1e114, "septentrigintillón"),
|
||||
(1e117, "octotrigintillón"),
|
||||
(1e120, "noventrigintillón"),
|
||||
(1e123, "quadragintillón"),
|
||||
(1e153, "quinquagintillón"),
|
||||
(1e183, "sexagintillón"),
|
||||
(1e213, "septuagintillón"),
|
||||
(1e243, "octogintillón"),
|
||||
(1e273, "nonagintillón"),
|
||||
(1e303, "centillón"),
|
||||
(1e306, "uncentillón"),
|
||||
(1e309, "duocentillón"),
|
||||
(1e312, "trescentillón"),
|
||||
(1e333, "decicentillón"),
|
||||
(1e336, "undecicentillón"),
|
||||
(1e363, "viginticentillón"),
|
||||
(1e366, "unviginticentillón"),
|
||||
(1e393, "trigintacentillón"),
|
||||
(1e423, "quadragintacentillón"),
|
||||
(1e453, "quinquagintacentillón"),
|
||||
(1e483, "sexagintacentillón"),
|
||||
(1e513, "septuagintacentillón"),
|
||||
(1e543, "ctogintacentillón"),
|
||||
(1e573, "nonagintacentillón"),
|
||||
(1e603, "ducentillón"),
|
||||
(1e903, "trecentillón"),
|
||||
(1e1203, "quadringentillón"),
|
||||
(1e1503, "quingentillón"),
|
||||
(1e1803, "sexcentillón"),
|
||||
(1e2103, "septingentillón"),
|
||||
(1e2403, "octingentillón"),
|
||||
(1e2703, "nongentillón"),
|
||||
(1e3003, "millinillón")
|
||||
])
|
||||
|
||||
# TODO: female forms.
|
||||
_ORDINAL_STRING_BASE_ES = {
|
||||
1: 'primero',
|
||||
2: 'segundo',
|
||||
3: 'tercero',
|
||||
4: 'cuarto',
|
||||
5: 'quinto',
|
||||
6: 'sexto',
|
||||
7: 'séptimo',
|
||||
8: 'octavo',
|
||||
9: 'noveno',
|
||||
10: 'décimo',
|
||||
11: 'undécimo',
|
||||
12: 'duodécimo',
|
||||
13: 'decimotercero',
|
||||
14: 'decimocuarto',
|
||||
15: 'decimoquinto',
|
||||
16: 'decimosexto',
|
||||
17: 'decimoséptimo',
|
||||
18: 'decimoctavo',
|
||||
19: 'decimonoveno',
|
||||
20: 'vigésimo',
|
||||
30: 'trigésimo',
|
||||
40: "cuadragésimo",
|
||||
50: "quincuagésimo",
|
||||
60: "sexagésimo",
|
||||
70: "septuagésimo",
|
||||
80: "octogésimo",
|
||||
90: "nonagésimo",
|
||||
10e3: "centésimó",
|
||||
1e3: "milésimo"
|
||||
}
|
||||
|
||||
|
||||
_SHORT_ORDINAL_STRING_ES = {
|
||||
1e6: "millonésimo",
|
||||
1e9: "milmillonésimo",
|
||||
1e12: "billonésimo",
|
||||
1e15: "milbillonésimo",
|
||||
1e18: "trillonésimo",
|
||||
1e21: "miltrillonésimo",
|
||||
1e24: "cuatrillonésimo",
|
||||
1e27: "milcuatrillonésimo",
|
||||
1e30: "quintillonésimo",
|
||||
1e33: "milquintillonésimo"
|
||||
# TODO > 1e-33
|
||||
}
|
||||
_SHORT_ORDINAL_STRING_ES.update(_ORDINAL_STRING_BASE_ES)
|
||||
|
||||
|
||||
_LONG_ORDINAL_STRING_ES = {
|
||||
1e6: "millonésimo",
|
||||
1e12: "billionth",
|
||||
1e18: "trillonésimo",
|
||||
1e24: "cuatrillonésimo",
|
||||
1e30: "quintillonésimo",
|
||||
1e36: "sextillonésimo",
|
||||
1e42: "septillonésimo",
|
||||
1e48: "octillonésimo",
|
||||
1e54: "nonillonésimo",
|
||||
1e60: "decillonésimo"
|
||||
# TODO > 1e60
|
||||
}
|
||||
_LONG_ORDINAL_STRING_ES.update(_ORDINAL_STRING_BASE_ES)
|
|
@ -1,245 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright 2019 Mycroft AI Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
from collections import OrderedDict
|
||||
|
||||
|
||||
_ARTICLES = {'de', 'het'}
|
||||
|
||||
|
||||
_NUM_STRING_NL = {
|
||||
0: 'nul',
|
||||
1: 'een',
|
||||
2: 'twee',
|
||||
3: 'drie',
|
||||
4: 'vier',
|
||||
5: 'vijf',
|
||||
6: 'zes',
|
||||
7: 'zeven',
|
||||
8: 'acht',
|
||||
9: 'negen',
|
||||
10: 'tien',
|
||||
11: 'elf',
|
||||
12: 'twaalf',
|
||||
13: 'dertien',
|
||||
14: 'veertien',
|
||||
15: 'vijftien',
|
||||
16: 'zestien',
|
||||
17: 'zeventien',
|
||||
18: 'achttien',
|
||||
19: 'negentien',
|
||||
20: 'twintig',
|
||||
30: 'dertig',
|
||||
40: 'veertig',
|
||||
50: 'vijftig',
|
||||
60: 'zestig',
|
||||
70: 'zeventig',
|
||||
80: 'tachtig',
|
||||
90: 'negentig'
|
||||
}
|
||||
|
||||
|
||||
_FRACTION_STRING_NL = {
|
||||
2: 'half',
|
||||
3: 'derde',
|
||||
4: 'vierde',
|
||||
5: 'vijfde',
|
||||
6: 'zesde',
|
||||
7: 'zevende',
|
||||
8: 'achtste',
|
||||
9: 'negende',
|
||||
10: 'tiende',
|
||||
11: 'elfde',
|
||||
12: 'twaalfde',
|
||||
13: 'dertiende',
|
||||
14: 'veertiende',
|
||||
15: 'vijftiende',
|
||||
16: 'zestiende',
|
||||
17: 'zeventiende',
|
||||
18: 'achttiende',
|
||||
19: 'negentiende',
|
||||
20: 'twintigste'
|
||||
}
|
||||
|
||||
|
||||
_LONG_SCALE_NL = OrderedDict([
|
||||
(100, 'honderd'),
|
||||
(1000, 'duizend'),
|
||||
(1000000, 'miljoen'),
|
||||
(1e12, "biljoen"),
|
||||
(1e18, 'triljoen'),
|
||||
(1e24, "quadriljoen"),
|
||||
(1e30, "quintillion"),
|
||||
(1e36, "sextillion"),
|
||||
(1e42, "septillion"),
|
||||
(1e48, "octillion"),
|
||||
(1e54, "nonillion"),
|
||||
(1e60, "decillion"),
|
||||
(1e66, "undecillion"),
|
||||
(1e72, "duodecillion"),
|
||||
(1e78, "tredecillion"),
|
||||
(1e84, "quattuordecillion"),
|
||||
(1e90, "quinquadecillion"),
|
||||
(1e96, "sedecillion"),
|
||||
(1e102, "septendecillion"),
|
||||
(1e108, "octodecillion"),
|
||||
(1e114, "novendecillion"),
|
||||
(1e120, "vigintillion"),
|
||||
(1e306, "unquinquagintillion"),
|
||||
(1e312, "duoquinquagintillion"),
|
||||
(1e336, "sesquinquagintillion"),
|
||||
(1e366, "unsexagintillion")
|
||||
])
|
||||
|
||||
|
||||
_SHORT_SCALE_NL = OrderedDict([
|
||||
(100, 'honderd'),
|
||||
(1000, 'duizend'),
|
||||
(1000000, 'miljoen'),
|
||||
(1e9, "miljard"),
|
||||
(1e12, 'biljoen'),
|
||||
(1e15, "quadrillion"),
|
||||
(1e18, "quintiljoen"),
|
||||
(1e21, "sextiljoen"),
|
||||
(1e24, "septiljoen"),
|
||||
(1e27, "octiljoen"),
|
||||
(1e30, "noniljoen"),
|
||||
(1e33, "deciljoen"),
|
||||
(1e36, "undeciljoen"),
|
||||
(1e39, "duodeciljoen"),
|
||||
(1e42, "tredeciljoen"),
|
||||
(1e45, "quattuordeciljoen"),
|
||||
(1e48, "quinquadeciljoen"),
|
||||
(1e51, "sedeciljoen"),
|
||||
(1e54, "septendeciljoen"),
|
||||
(1e57, "octodeciljoen"),
|
||||
(1e60, "novendeciljoen"),
|
||||
(1e63, "vigintiljoen"),
|
||||
(1e66, "unvigintiljoen"),
|
||||
(1e69, "uuovigintiljoen"),
|
||||
(1e72, "tresvigintiljoen"),
|
||||
(1e75, "quattuorvigintiljoen"),
|
||||
(1e78, "quinquavigintiljoen"),
|
||||
(1e81, "qesvigintiljoen"),
|
||||
(1e84, "septemvigintiljoen"),
|
||||
(1e87, "octovigintiljoen"),
|
||||
(1e90, "novemvigintiljoen"),
|
||||
(1e93, "trigintiljoen"),
|
||||
(1e96, "untrigintiljoen"),
|
||||
(1e99, "duotrigintiljoen"),
|
||||
(1e102, "trestrigintiljoen"),
|
||||
(1e105, "quattuortrigintiljoen"),
|
||||
(1e108, "quinquatrigintiljoen"),
|
||||
(1e111, "sestrigintiljoen"),
|
||||
(1e114, "septentrigintiljoen"),
|
||||
(1e117, "octotrigintiljoen"),
|
||||
(1e120, "noventrigintiljoen"),
|
||||
(1e123, "quadragintiljoen"),
|
||||
(1e153, "quinquagintiljoen"),
|
||||
(1e183, "sexagintiljoen"),
|
||||
(1e213, "septuagintiljoen"),
|
||||
(1e243, "octogintiljoen"),
|
||||
(1e273, "nonagintiljoen"),
|
||||
(1e303, "centiljoen"),
|
||||
(1e306, "uncentiljoen"),
|
||||
(1e309, "duocentiljoen"),
|
||||
(1e312, "trescentiljoen"),
|
||||
(1e333, "decicentiljoen"),
|
||||
(1e336, "undecicentiljoen"),
|
||||
(1e363, "viginticentiljoen"),
|
||||
(1e366, "unviginticentiljoen"),
|
||||
(1e393, "trigintacentiljoen"),
|
||||
(1e423, "quadragintacentiljoen"),
|
||||
(1e453, "quinquagintacentiljoen"),
|
||||
(1e483, "sexagintacentiljoen"),
|
||||
(1e513, "septuagintacentiljoen"),
|
||||
(1e543, "ctogintacentiljoen"),
|
||||
(1e573, "nonagintacentiljoen"),
|
||||
(1e603, "ducentiljoen"),
|
||||
(1e903, "trecentiljoen"),
|
||||
(1e1203, "quadringentiljoen"),
|
||||
(1e1503, "quingentiljoen"),
|
||||
(1e1803, "sescentiljoen"),
|
||||
(1e2103, "septingentiljoen"),
|
||||
(1e2403, "octingentiljoen"),
|
||||
(1e2703, "nongentiljoen"),
|
||||
(1e3003, "milliniljoen")
|
||||
])
|
||||
|
||||
|
||||
_ORDINAL_STRING_BASE_NL = {
|
||||
1: 'eerste',
|
||||
2: 'tweede',
|
||||
3: 'derde',
|
||||
4: 'vierde',
|
||||
5: 'vijfde',
|
||||
6: 'zesde',
|
||||
7: 'zevende',
|
||||
8: 'achtste',
|
||||
9: 'negende',
|
||||
10: 'tiende',
|
||||
11: 'elfde',
|
||||
12: 'twaalfde',
|
||||
13: 'dertiende',
|
||||
14: 'veertiende',
|
||||
15: 'vijftiende',
|
||||
16: 'zestiende',
|
||||
17: 'zeventiende',
|
||||
18: 'achttiende',
|
||||
19: 'negentiende',
|
||||
20: 'twintigste',
|
||||
30: 'dertigste',
|
||||
40: "veertigste",
|
||||
50: "vijftigste",
|
||||
60: "zestigste",
|
||||
70: "zeventigste",
|
||||
80: "tachtigste",
|
||||
90: "negentigste",
|
||||
10e3: "honderdste",
|
||||
1e3: "duizendste"
|
||||
}
|
||||
|
||||
|
||||
_SHORT_ORDINAL_STRING_NL = {
|
||||
1e6: "miloenste",
|
||||
1e9: "miljardste",
|
||||
1e12: "biljoenste",
|
||||
1e15: "biljardste",
|
||||
1e18: "triljoenste",
|
||||
1e21: "trijardste",
|
||||
1e24: "quadriljoenste",
|
||||
1e27: "quadriljardste",
|
||||
1e30: "quintiljoenste",
|
||||
1e33: "quintiljardste"
|
||||
# TODO > 1e-33
|
||||
}
|
||||
_SHORT_ORDINAL_STRING_NL.update(_ORDINAL_STRING_BASE_NL)
|
||||
|
||||
|
||||
_LONG_ORDINAL_STRING_NL = {
|
||||
1e6: "miloenste",
|
||||
1e9: "miljardste",
|
||||
1e12: "biljoenste",
|
||||
1e15: "biljardste",
|
||||
1e18: "triljoenste",
|
||||
1e21: "trijardste",
|
||||
1e24: "quadriljoenste",
|
||||
1e27: "quadriljardste",
|
||||
1e30: "quintiljoenste",
|
||||
1e33: "quintiljardste"
|
||||
# TODO > 1e60
|
||||
}
|
||||
_LONG_ORDINAL_STRING_NL.update(_ORDINAL_STRING_BASE_NL)
|
|
@ -1,118 +0,0 @@
|
|||
# Undefined articles ["um", "uma", "uns", "umas"] can not be supressed,
|
||||
# in PT, "um cavalo" means "a horse" or "one horse".
|
||||
|
||||
_PT_ARTICLES = ["o", "a", "os", "as"]
|
||||
|
||||
_PT_NUMBERS = {
|
||||
"zero": 0,
|
||||
"um": 1,
|
||||
"uma": 1,
|
||||
"uns": 1,
|
||||
"umas": 1,
|
||||
"primeiro": 1,
|
||||
"segundo": 2,
|
||||
"terceiro": 3,
|
||||
"dois": 2,
|
||||
"duas": 2,
|
||||
"tres": 3,
|
||||
"três": 3,
|
||||
"quatro": 4,
|
||||
"cinco": 5,
|
||||
"seis": 6,
|
||||
"sete": 7,
|
||||
"oito": 8,
|
||||
"nove": 9,
|
||||
"dez": 10,
|
||||
"onze": 11,
|
||||
"doze": 12,
|
||||
"treze": 13,
|
||||
"catorze": 14,
|
||||
"quinze": 15,
|
||||
"dezasseis": 16,
|
||||
"dezassete": 17,
|
||||
"dezoito": 18,
|
||||
"dezanove": 19,
|
||||
"vinte": 20,
|
||||
"trinta": 30,
|
||||
"quarenta": 40,
|
||||
"cinquenta": 50,
|
||||
"sessenta": 60,
|
||||
"setenta": 70,
|
||||
"oitenta": 80,
|
||||
"noventa": 90,
|
||||
"cem": 100,
|
||||
"cento": 100,
|
||||
"duzentos": 200,
|
||||
"duzentas": 200,
|
||||
"trezentos": 300,
|
||||
"trezentas": 300,
|
||||
"quatrocentos": 400,
|
||||
"quatrocentas": 400,
|
||||
"quinhentos": 500,
|
||||
"quinhentas": 500,
|
||||
"seiscentos": 600,
|
||||
"seiscentas": 600,
|
||||
"setecentos": 700,
|
||||
"setecentas": 700,
|
||||
"oitocentos": 800,
|
||||
"oitocentas": 800,
|
||||
"novecentos": 900,
|
||||
"novecentas": 900,
|
||||
"mil": 1000,
|
||||
"milh�o": 1000000}
|
||||
|
||||
_FRACTION_STRING_PT = {
|
||||
2: 'meio',
|
||||
3: 'terço',
|
||||
4: 'quarto',
|
||||
5: 'quinto',
|
||||
6: 'sexto',
|
||||
7: 'sétimo',
|
||||
8: 'oitavo',
|
||||
9: 'nono',
|
||||
10: 'décimo',
|
||||
11: 'onze avos',
|
||||
12: 'doze avos',
|
||||
13: 'treze avos',
|
||||
14: 'catorze avos',
|
||||
15: 'quinze avos',
|
||||
16: 'dezasseis avos',
|
||||
17: 'dezassete avos',
|
||||
18: 'dezoito avos',
|
||||
19: 'dezanove avos',
|
||||
20: 'vigésimo',
|
||||
30: 'trigésimo',
|
||||
100: 'centésimo',
|
||||
1000: 'milésimo'
|
||||
}
|
||||
|
||||
_NUM_STRING_PT = {
|
||||
0: 'zero',
|
||||
1: 'um',
|
||||
2: 'dois',
|
||||
3: 'três',
|
||||
4: 'quatro',
|
||||
5: 'cinco',
|
||||
6: 'seis',
|
||||
7: 'sete',
|
||||
8: 'oito',
|
||||
9: 'nove',
|
||||
10: 'dez',
|
||||
11: 'onze',
|
||||
12: 'doze',
|
||||
13: 'treze',
|
||||
14: 'catorze',
|
||||
15: 'quinze',
|
||||
16: 'dezasseis',
|
||||
17: 'dezassete',
|
||||
18: 'dezoito',
|
||||
19: 'dezanove',
|
||||
20: 'vinte',
|
||||
30: 'trinta',
|
||||
40: 'quarenta',
|
||||
50: 'cinquenta',
|
||||
60: 'sessenta',
|
||||
70: 'setenta',
|
||||
80: 'oitenta',
|
||||
90: 'noventa'
|
||||
}
|
|
@ -14,34 +14,9 @@
|
|||
# limitations under the License.
|
||||
#
|
||||
|
||||
"""File kept for backwards compatibility.
|
||||
|
||||
def convert_to_mixed_fraction(number, denominators=range(1, 21)):
|
||||
"""
|
||||
Convert floats to components of a mixed fraction representation
|
||||
TODO: Remove in 20.02
|
||||
"""
|
||||
|
||||
Returns the closest fractional representation using the
|
||||
provided denominators. For example, 4.500002 would become
|
||||
the whole number 4, the numerator 1 and the denominator 2
|
||||
|
||||
Args:
|
||||
number (float): number for convert
|
||||
denominators (iter of ints): denominators to use, default [1 .. 20]
|
||||
Returns:
|
||||
whole, numerator, denominator (int): Integers of the mixed fraction
|
||||
"""
|
||||
int_number = int(number)
|
||||
if int_number == number:
|
||||
return int_number, 0, 1 # whole number, no fraction
|
||||
|
||||
frac_number = abs(number - int_number)
|
||||
if not denominators:
|
||||
denominators = range(1, 21)
|
||||
|
||||
for denominator in denominators:
|
||||
numerator = abs(frac_number) * denominator
|
||||
if abs(numerator - round(numerator)) < 0.01: # 0.01 accuracy
|
||||
break
|
||||
else:
|
||||
return None
|
||||
|
||||
return int_number, int(round(numerator)), denominator
|
||||
from lingua_franca.lang.format_common import convert_to_mixed_fraction
|
||||
|
|
|
@ -14,383 +14,14 @@
|
|||
# limitations under the License.
|
||||
#
|
||||
|
||||
from mycroft.util.lang.format_common import convert_to_mixed_fraction
|
||||
from math import floor
|
||||
"""File kept for backwards compatibility.
|
||||
|
||||
months = ['januar', 'februar', 'märz', 'april', 'mai', 'juni',
|
||||
'juli', 'august', 'september', 'oktober', 'november',
|
||||
'dezember']
|
||||
|
||||
NUM_STRING_DA = {
|
||||
0: 'nul',
|
||||
1: 'en',
|
||||
2: 'to',
|
||||
3: 'tre',
|
||||
4: 'fire',
|
||||
5: 'fem',
|
||||
6: 'seks',
|
||||
7: 'syv',
|
||||
8: 'otte',
|
||||
9: 'ni',
|
||||
10: 'ti',
|
||||
11: 'elve',
|
||||
12: 'tolv',
|
||||
13: 'tretten',
|
||||
14: 'fjorten',
|
||||
15: 'femten',
|
||||
16: 'seksten',
|
||||
17: 'sytten',
|
||||
18: 'atten',
|
||||
19: 'nitten',
|
||||
20: 'tyve',
|
||||
30: 'tredive',
|
||||
40: 'fyrre',
|
||||
50: 'halvtres',
|
||||
60: 'tres',
|
||||
70: 'halvfjers',
|
||||
80: 'firs',
|
||||
90: 'halvfems',
|
||||
100: 'hundrede'
|
||||
}
|
||||
|
||||
NUM_POWERS_OF_TEN = [
|
||||
'hundred',
|
||||
'tusind',
|
||||
'million',
|
||||
'milliard',
|
||||
'billion',
|
||||
'billiard',
|
||||
'trillion',
|
||||
'trilliard'
|
||||
]
|
||||
|
||||
FRACTION_STRING_DA = {
|
||||
2: 'halv',
|
||||
3: 'trediedel',
|
||||
4: 'fjerdedel',
|
||||
5: 'femtedel',
|
||||
6: 'sjettedel',
|
||||
7: 'syvendedel',
|
||||
8: 'ottendedel',
|
||||
9: 'niendedel',
|
||||
10: 'tiendedel',
|
||||
11: 'elftedel',
|
||||
12: 'tolvtedel',
|
||||
13: 'trettendedel',
|
||||
14: 'fjortendedel',
|
||||
15: 'femtendedel',
|
||||
16: 'sejstendedel',
|
||||
17: 'syttendedel',
|
||||
18: 'attendedel',
|
||||
19: 'nittendedel',
|
||||
20: 'tyvendedel'
|
||||
}
|
||||
|
||||
# Numbers below 1 million are written in one word in German, yielding very
|
||||
# long words
|
||||
# In some circumstances it may better to seperate individual words
|
||||
# Set EXTRA_SPACE=" " for separating numbers below 1 million (
|
||||
# orthographically incorrect)
|
||||
# Set EXTRA_SPACE="" for correct spelling, this is standard
|
||||
|
||||
# EXTRA_SPACE = " "
|
||||
EXTRA_SPACE = ""
|
||||
|
||||
|
||||
def nice_number_da(number, speech, denominators=range(1, 21)):
|
||||
""" Danish helper for nice_number
|
||||
This function formats a float to human understandable functions. Like
|
||||
4.5 becomes "4 einhalb" for speech and "4 1/2" for text
|
||||
Args:
|
||||
number (int or float): the float to format
|
||||
speech (bool): format for speech (True) or display (False)
|
||||
denominators (iter of ints): denominators to use, default [1 .. 20]
|
||||
Returns:
|
||||
(str): The formatted string.
|
||||
"""
|
||||
result = convert_to_mixed_fraction(number, denominators)
|
||||
if not result:
|
||||
# Give up, just represent as a 3 decimal number
|
||||
return str(round(number, 3)).replace(".", ",")
|
||||
whole, num, den = result
|
||||
if not speech:
|
||||
if num == 0:
|
||||
# TODO: Number grouping? E.g. "1,000,000"
|
||||
return str(whole)
|
||||
else:
|
||||
return '{} {}/{}'.format(whole, num, den)
|
||||
if num == 0:
|
||||
return str(whole)
|
||||
den_str = FRACTION_STRING_DA[den]
|
||||
if whole == 0:
|
||||
if num == 1:
|
||||
return_string = '{} {}'.format(num, den_str)
|
||||
else:
|
||||
return_string = '{} {}e'.format(num, den_str)
|
||||
else:
|
||||
if num == 1:
|
||||
return_string = '{} og {} {}'.format(whole, num, den_str)
|
||||
else:
|
||||
return_string = '{} og {} {}e'.format(whole, num, den_str)
|
||||
|
||||
return return_string
|
||||
|
||||
|
||||
def pronounce_number_da(num, places=2):
|
||||
"""
|
||||
Convert a number to its spoken equivalent
|
||||
For example, '5.2' would return 'five point two'
|
||||
Args:
|
||||
num(float or int): the number to pronounce (set limit below)
|
||||
places(int): maximum decimal places to speak
|
||||
Returns:
|
||||
(str): The pronounced number
|
||||
|
||||
"""
|
||||
|
||||
def pronounce_triplet_da(num):
|
||||
result = ""
|
||||
num = floor(num)
|
||||
if num > 99:
|
||||
hundreds = floor(num / 100)
|
||||
if hundreds > 0:
|
||||
if hundreds == 1:
|
||||
result += 'et' + 'hundrede' + EXTRA_SPACE
|
||||
else:
|
||||
result += NUM_STRING_DA[hundreds] + \
|
||||
'hundrede' + EXTRA_SPACE
|
||||
num -= hundreds * 100
|
||||
if num == 0:
|
||||
result += '' # do nothing
|
||||
elif num == 1:
|
||||
result += 'et'
|
||||
elif num <= 20:
|
||||
result += NUM_STRING_DA[num] + EXTRA_SPACE
|
||||
elif num > 20:
|
||||
ones = num % 10
|
||||
tens = num - ones
|
||||
if ones > 0:
|
||||
result += NUM_STRING_DA[ones] + EXTRA_SPACE
|
||||
if tens > 0:
|
||||
result += 'og' + EXTRA_SPACE
|
||||
if tens > 0:
|
||||
result += NUM_STRING_DA[tens] + EXTRA_SPACE
|
||||
|
||||
return result
|
||||
|
||||
def pronounce_fractional_da(num, places):
|
||||
# fixed number of places even with trailing zeros
|
||||
result = ""
|
||||
place = 10
|
||||
while places > 0:
|
||||
# doesn't work with 1.0001 and places = 2: int(
|
||||
# num*place) % 10 > 0 and places > 0:
|
||||
result += " " + NUM_STRING_DA[int(num * place) % 10]
|
||||
place *= 10
|
||||
places -= 1
|
||||
return result
|
||||
|
||||
def pronounce_whole_number_da(num, scale_level=0):
|
||||
if num == 0:
|
||||
return ''
|
||||
|
||||
num = floor(num)
|
||||
result = ''
|
||||
last_triplet = num % 1000
|
||||
|
||||
if last_triplet == 1:
|
||||
if scale_level == 0:
|
||||
if result != '':
|
||||
result += '' + 'et'
|
||||
else:
|
||||
result += "en"
|
||||
elif scale_level == 1:
|
||||
result += 'et' + EXTRA_SPACE + 'tusinde' + EXTRA_SPACE
|
||||
else:
|
||||
result += "en " + NUM_POWERS_OF_TEN[scale_level] + ' '
|
||||
elif last_triplet > 1:
|
||||
result += pronounce_triplet_da(last_triplet)
|
||||
if scale_level == 1:
|
||||
result += 'tusinde' + EXTRA_SPACE
|
||||
if scale_level >= 2:
|
||||
result += "og" + NUM_POWERS_OF_TEN[scale_level]
|
||||
if scale_level >= 2:
|
||||
if scale_level % 2 == 0:
|
||||
result += "er" # MillionER
|
||||
result += "er " # MilliardER, MillioneER
|
||||
|
||||
num = floor(num / 1000)
|
||||
scale_level += 1
|
||||
return pronounce_whole_number_da(num,
|
||||
scale_level) + result + EXTRA_SPACE
|
||||
|
||||
result = ""
|
||||
if abs(num) >= 1000000000000000000000000: # cannot do more than this
|
||||
return str(num)
|
||||
elif num == 0:
|
||||
return str(NUM_STRING_DA[0])
|
||||
elif num < 0:
|
||||
return "minus " + pronounce_number_da(abs(num), places)
|
||||
else:
|
||||
if num == int(num):
|
||||
return pronounce_whole_number_da(num)
|
||||
else:
|
||||
whole_number_part = floor(num)
|
||||
fractional_part = num - whole_number_part
|
||||
result += pronounce_whole_number_da(whole_number_part)
|
||||
if places > 0:
|
||||
result += " komma"
|
||||
result += pronounce_fractional_da(fractional_part, places)
|
||||
return result
|
||||
|
||||
|
||||
def pronounce_ordinal_da(num):
|
||||
# ordinals for 1, 3, 7 and 8 are irregular
|
||||
# this produces the base form, it will have to be adapted for genus,
|
||||
# casus, numerus
|
||||
|
||||
ordinals = ["nulte", "første", "anden", "tredie", "fjerde", "femte",
|
||||
"sjette", "syvende", "ottende", "niende", "tiende"]
|
||||
|
||||
# only for whole positive numbers including zero
|
||||
if num < 0 or num != int(num):
|
||||
return num
|
||||
if num < 10:
|
||||
return ordinals[num]
|
||||
if num < 30:
|
||||
if pronounce_number_da(num)[-1:] == 'e':
|
||||
return pronounce_number_da(num) + "nde"
|
||||
else:
|
||||
return pronounce_number_da(num) + "ende"
|
||||
if num < 40:
|
||||
return pronounce_number_da(num) + "fte"
|
||||
else:
|
||||
if pronounce_number_da(num)[-1:] == 'e':
|
||||
return pronounce_number_da(num) + "nde"
|
||||
else:
|
||||
return pronounce_number_da(num) + "ende"
|
||||
|
||||
|
||||
def nice_time_da(dt, speech=True, use_24hour=False, use_ampm=False):
|
||||
"""
|
||||
Format a time to a comfortable human format
|
||||
|
||||
For example, generate 'five thirty' for speech or '5:30' for
|
||||
text display.
|
||||
|
||||
Args:
|
||||
dt (datetime): date to format (assumes already in local timezone)
|
||||
speech (bool): format for speech (default/True) or display (False)=Fal
|
||||
use_24hour (bool): output in 24-hour/military or 12-hour format
|
||||
use_ampm (bool): include the am/pm for 12-hour format
|
||||
Returns:
|
||||
(str): The formatted time string
|
||||
"""
|
||||
if use_24hour:
|
||||
# e.g. "03:01" or "14:22"
|
||||
string = dt.strftime("%H:%M")
|
||||
else:
|
||||
if use_ampm:
|
||||
# e.g. "3:01 AM" or "2:22 PM"
|
||||
string = dt.strftime("%I:%M %p")
|
||||
else:
|
||||
# e.g. "3:01" or "2:22"
|
||||
string = dt.strftime("%I:%M")
|
||||
|
||||
if not speech:
|
||||
return string
|
||||
|
||||
# Generate a speakable version of the time
|
||||
speak = ""
|
||||
if use_24hour:
|
||||
if dt.hour == 1:
|
||||
speak += "et" # 01:00 is "et" not "en"
|
||||
else:
|
||||
speak += pronounce_number_da(dt.hour)
|
||||
if not dt.minute == 0:
|
||||
if dt.minute < 10:
|
||||
speak += ' nul'
|
||||
speak += " " + pronounce_number_da(dt.minute)
|
||||
|
||||
return speak # ampm is ignored when use_24hour is true
|
||||
else:
|
||||
if dt.hour == 0 and dt.minute == 0:
|
||||
return "midnat"
|
||||
if dt.hour == 12 and dt.minute == 0:
|
||||
return "middag"
|
||||
# TODO: "half past 3", "a quarter of 4" and other idiomatic times
|
||||
|
||||
if dt.hour == 0:
|
||||
speak += pronounce_number_da(12)
|
||||
elif dt.hour <= 13:
|
||||
if dt.hour == 1 or dt.hour == 13: # 01:00 and 13:00 is "et"
|
||||
speak += 'et'
|
||||
else:
|
||||
speak += pronounce_number_da(dt.hour)
|
||||
else:
|
||||
speak += pronounce_number_da(dt.hour - 12)
|
||||
|
||||
if not dt.minute == 0:
|
||||
if dt.minute < 10:
|
||||
speak += ' nul'
|
||||
speak += " " + pronounce_number_da(dt.minute)
|
||||
|
||||
if use_ampm:
|
||||
if dt.hour > 11:
|
||||
if dt.hour < 18:
|
||||
# 12:01 - 17:59 nachmittags/afternoon
|
||||
speak += " om eftermiddagen"
|
||||
elif dt.hour < 22:
|
||||
# 18:00 - 21:59 abends/evening
|
||||
speak += " om aftenen"
|
||||
else:
|
||||
# 22:00 - 23:59 nachts/at night
|
||||
speak += " om natten"
|
||||
elif dt.hour < 3:
|
||||
# 00:01 - 02:59 nachts/at night
|
||||
speak += " om natten"
|
||||
else:
|
||||
# 03:00 - 11:59 morgens/in the morning
|
||||
speak += " om morgenen"
|
||||
|
||||
return speak
|
||||
|
||||
|
||||
def nice_response_da(text):
|
||||
# check for months and call nice_ordinal_da declension of ordinals
|
||||
# replace "^" with "hoch" (to the power of)
|
||||
words = text.split()
|
||||
|
||||
for idx, word in enumerate(words):
|
||||
if word.lower() in months:
|
||||
text = nice_ordinal_da(text)
|
||||
|
||||
if word == '^':
|
||||
wordNext = words[idx + 1] if idx + 1 < len(words) else ""
|
||||
if wordNext.isnumeric():
|
||||
words[idx] = "opløftet i"
|
||||
text = " ".join(words)
|
||||
return text
|
||||
|
||||
|
||||
def nice_ordinal_da(text):
|
||||
# check for months for declension of ordinals before months
|
||||
# depending on articles/prepositions
|
||||
normalized_text = text
|
||||
words = text.split()
|
||||
|
||||
for idx, word in enumerate(words):
|
||||
wordNext = words[idx + 1] if idx + 1 < len(words) else ""
|
||||
wordPrev = words[idx - 1] if idx > 0 else ""
|
||||
if word[-1:] == ".":
|
||||
if word[:-1].isdecimal():
|
||||
if wordNext.lower() in months:
|
||||
word = pronounce_ordinal_da(int(word[:-1]))
|
||||
if wordPrev.lower() in ["om", "den", "fra", "til",
|
||||
"(fra", "(om", "til"]:
|
||||
word += "n"
|
||||
elif wordPrev.lower() not in ["den"]:
|
||||
word += "r"
|
||||
words[idx] = word
|
||||
normalized_text = " ".join(words)
|
||||
return normalized_text
|
||||
TODO: Remove in 20.02
|
||||
"""
|
||||
from lingua_franca.lang.format_da import (months, NUM_STRING_DA,
|
||||
NUM_POWERS_OF_TEN,
|
||||
FRACTION_STRING_DA,
|
||||
EXTRA_SPACE,
|
||||
nice_number_da, pronounce_number_da,
|
||||
pronounce_ordinal_da, nice_time_da,
|
||||
nice_response_da, nice_ordinal_da)
|
||||
|
|
|
@ -13,373 +13,17 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
"""File kept for backwards compatibility
|
||||
|
||||
from mycroft.util.lang.format_common import convert_to_mixed_fraction
|
||||
from math import floor
|
||||
|
||||
months = ['januar', 'februar', 'märz', 'april', 'mai', 'juni',
|
||||
'juli', 'august', 'september', 'oktober', 'november',
|
||||
'dezember']
|
||||
|
||||
NUM_STRING_DE = {
|
||||
0: 'null',
|
||||
1: 'ein', # ein Viertel etc., nicht eins Viertel
|
||||
2: 'zwei',
|
||||
3: 'drei',
|
||||
4: 'vier',
|
||||
5: 'fünf',
|
||||
6: 'sechs',
|
||||
7: 'sieben',
|
||||
8: 'acht',
|
||||
9: 'neun',
|
||||
10: 'zehn',
|
||||
11: 'elf',
|
||||
12: 'zwölf',
|
||||
13: 'dreizehn',
|
||||
14: 'vierzehn',
|
||||
15: 'fünfzehn',
|
||||
16: 'sechzehn',
|
||||
17: 'siebzehn',
|
||||
18: 'achtzehn',
|
||||
19: 'neunzehn',
|
||||
20: 'zwanzig',
|
||||
30: 'dreißig',
|
||||
40: 'vierzig',
|
||||
50: 'fünfzig',
|
||||
60: 'sechzig',
|
||||
70: 'siebzig',
|
||||
80: 'achtzig',
|
||||
90: 'neunzig',
|
||||
100: 'hundert'
|
||||
}
|
||||
|
||||
# German uses "long scale" https://en.wikipedia.org/wiki/Long_and_short_scales
|
||||
# Currently, numbers are limited to 1000000000000000000000000,
|
||||
# but NUM_POWERS_OF_TEN can be extended to include additional number words
|
||||
TODO: Remove in 20.02
|
||||
"""
|
||||
|
||||
|
||||
NUM_POWERS_OF_TEN = [
|
||||
'', 'tausend', 'Million', 'Milliarde', 'Billion', 'Billiarde', 'Trillion',
|
||||
'Trilliarde'
|
||||
]
|
||||
|
||||
FRACTION_STRING_DE = {
|
||||
2: 'halb',
|
||||
3: 'drittel',
|
||||
4: 'viertel',
|
||||
5: 'fünftel',
|
||||
6: 'sechstel',
|
||||
7: 'siebtel',
|
||||
8: 'achtel',
|
||||
9: 'neuntel',
|
||||
10: 'zehntel',
|
||||
11: 'elftel',
|
||||
12: 'zwölftel',
|
||||
13: 'dreizehntel',
|
||||
14: 'vierzehntel',
|
||||
15: 'fünfzehntel',
|
||||
16: 'sechzehntel',
|
||||
17: 'siebzehntel',
|
||||
18: 'achtzehntel',
|
||||
19: 'neunzehntel',
|
||||
20: 'zwanzigstel'
|
||||
}
|
||||
|
||||
# Numbers below 1 million are written in one word in German, yielding very
|
||||
# long words
|
||||
# In some circumstances it may better to seperate individual words
|
||||
# Set EXTRA_SPACE=" " for separating numbers below 1 million (
|
||||
# orthographically incorrect)
|
||||
# Set EXTRA_SPACE="" for correct spelling, this is standard
|
||||
|
||||
# EXTRA_SPACE = " "
|
||||
EXTRA_SPACE = ""
|
||||
|
||||
|
||||
def nice_number_de(number, speech, denominators=range(1, 21)):
|
||||
""" German helper for nice_number
|
||||
This function formats a float to human understandable functions. Like
|
||||
4.5 becomes "4 einhalb" for speech and "4 1/2" for text
|
||||
Args:
|
||||
number (int or float): the float to format
|
||||
speech (bool): format for speech (True) or display (False)
|
||||
denominators (iter of ints): denominators to use, default [1 .. 20]
|
||||
Returns:
|
||||
(str): The formatted string.
|
||||
"""
|
||||
result = convert_to_mixed_fraction(number, denominators)
|
||||
if not result:
|
||||
# Give up, just represent as a 3 decimal number
|
||||
return str(round(number, 3)).replace(".", ",")
|
||||
whole, num, den = result
|
||||
if not speech:
|
||||
if num == 0:
|
||||
# TODO: Number grouping? E.g. "1,000,000"
|
||||
return str(whole)
|
||||
else:
|
||||
return '{} {}/{}'.format(whole, num, den)
|
||||
if num == 0:
|
||||
return str(whole)
|
||||
den_str = FRACTION_STRING_DE[den]
|
||||
if whole == 0:
|
||||
if num == 1:
|
||||
return_string = 'ein {}'.format(den_str)
|
||||
else:
|
||||
return_string = '{} {}'.format(num, den_str)
|
||||
elif num == 1:
|
||||
return_string = '{} und ein {}'.format(whole, den_str)
|
||||
else:
|
||||
return_string = '{} und {} {}'.format(whole, num, den_str)
|
||||
|
||||
return return_string
|
||||
|
||||
|
||||
def pronounce_number_de(num, places=2):
|
||||
"""
|
||||
Convert a number to its spoken equivalent
|
||||
For example, '5.2' would return 'five point two'
|
||||
Args:
|
||||
num(float or int): the number to pronounce (set limit below)
|
||||
places(int): maximum decimal places to speak
|
||||
Returns:
|
||||
(str): The pronounced number
|
||||
|
||||
"""
|
||||
|
||||
def pronounce_triplet_de(num):
|
||||
result = ""
|
||||
num = floor(num)
|
||||
if num > 99:
|
||||
hundreds = floor(num / 100)
|
||||
if hundreds > 0:
|
||||
result += NUM_STRING_DE[
|
||||
hundreds] + EXTRA_SPACE + 'hundert' + EXTRA_SPACE
|
||||
num -= hundreds * 100
|
||||
if num == 0:
|
||||
result += '' # do nothing
|
||||
elif num == 1:
|
||||
result += 'eins' # need the s for the last digit
|
||||
elif num <= 20:
|
||||
result += NUM_STRING_DE[num] # + EXTRA_SPACE
|
||||
elif num > 20:
|
||||
ones = num % 10
|
||||
tens = num - ones
|
||||
if ones > 0:
|
||||
result += NUM_STRING_DE[ones] + EXTRA_SPACE
|
||||
if tens > 0:
|
||||
result += 'und' + EXTRA_SPACE
|
||||
if tens > 0:
|
||||
result += NUM_STRING_DE[tens] + EXTRA_SPACE
|
||||
return result
|
||||
|
||||
def pronounce_fractional_de(num,
|
||||
places): # fixed number of places even with
|
||||
# trailing zeros
|
||||
result = ""
|
||||
place = 10
|
||||
while places > 0: # doesn't work with 1.0001 and places = 2: int(
|
||||
# num*place) % 10 > 0 and places > 0:
|
||||
result += " " + NUM_STRING_DE[int(num * place) % 10]
|
||||
if int(num * place) % 10 == 1:
|
||||
result += 's' # "1" is pronounced "eins" after the decimal
|
||||
# point
|
||||
place *= 10
|
||||
places -= 1
|
||||
return result
|
||||
|
||||
def pronounce_whole_number_de(num, scale_level=0):
|
||||
if num == 0:
|
||||
return ''
|
||||
|
||||
num = floor(num)
|
||||
result = ''
|
||||
last_triplet = num % 1000
|
||||
|
||||
if last_triplet == 1:
|
||||
if scale_level == 0:
|
||||
if result != '':
|
||||
result += '' + 'eins'
|
||||
else:
|
||||
result += "eins"
|
||||
elif scale_level == 1:
|
||||
result += 'ein' + EXTRA_SPACE + 'tausend' + EXTRA_SPACE
|
||||
else:
|
||||
result += "eine " + NUM_POWERS_OF_TEN[scale_level] + ' '
|
||||
elif last_triplet > 1:
|
||||
result += pronounce_triplet_de(last_triplet)
|
||||
if scale_level == 1:
|
||||
# result += EXTRA_SPACE
|
||||
result += 'tausend' + EXTRA_SPACE
|
||||
if scale_level >= 2:
|
||||
# if EXTRA_SPACE == '':
|
||||
# result += " "
|
||||
result += " " + NUM_POWERS_OF_TEN[scale_level]
|
||||
if scale_level >= 2:
|
||||
if scale_level % 2 == 0:
|
||||
result += "e" # MillionE
|
||||
result += "n " # MilliardeN, MillioneN
|
||||
|
||||
num = floor(num / 1000)
|
||||
scale_level += 1
|
||||
return pronounce_whole_number_de(num,
|
||||
scale_level) + result # + EXTRA_SPACE
|
||||
|
||||
result = ""
|
||||
if abs(num) >= 1000000000000000000000000: # cannot do more than this
|
||||
return str(num)
|
||||
elif num == 0:
|
||||
return str(NUM_STRING_DE[0])
|
||||
elif num < 0:
|
||||
return "minus " + pronounce_number_de(abs(num), places)
|
||||
else:
|
||||
if num == int(num):
|
||||
return pronounce_whole_number_de(num)
|
||||
else:
|
||||
whole_number_part = floor(num)
|
||||
fractional_part = num - whole_number_part
|
||||
result += pronounce_whole_number_de(whole_number_part)
|
||||
if places > 0:
|
||||
result += " Komma"
|
||||
result += pronounce_fractional_de(fractional_part, places)
|
||||
return result
|
||||
|
||||
|
||||
def pronounce_ordinal_de(num):
|
||||
# ordinals for 1, 3, 7 and 8 are irregular
|
||||
# this produces the base form, it will have to be adapted for genus,
|
||||
# casus, numerus
|
||||
|
||||
ordinals = ["nullte", "erste", "zweite", "dritte", "vierte", "fünfte",
|
||||
"sechste", "siebte", "achte"]
|
||||
|
||||
# only for whole positive numbers including zero
|
||||
if num < 0 or num != int(num):
|
||||
return num
|
||||
elif num < 9:
|
||||
return ordinals[num]
|
||||
elif num < 20:
|
||||
return pronounce_number_de(num) + "te"
|
||||
else:
|
||||
return pronounce_number_de(num) + "ste"
|
||||
|
||||
|
||||
def nice_time_de(dt, speech=True, use_24hour=False, use_ampm=False):
|
||||
"""
|
||||
Format a time to a comfortable human format
|
||||
|
||||
For example, generate 'five thirty' for speech or '5:30' for
|
||||
text display.
|
||||
|
||||
Args:
|
||||
dt (datetime): date to format (assumes already in local timezone)
|
||||
speech (bool): format for speech (default/True) or display (False)=Fal
|
||||
use_24hour (bool): output in 24-hour/military or 12-hour format
|
||||
use_ampm (bool): include the am/pm for 12-hour format
|
||||
Returns:
|
||||
(str): The formatted time string
|
||||
"""
|
||||
if not speech:
|
||||
if use_24hour:
|
||||
# e.g. "03:01" or "14:22"
|
||||
string = dt.strftime("%H:%M")
|
||||
else:
|
||||
if use_ampm:
|
||||
# e.g. "3:01 AM" or "2:22 PM"
|
||||
string = dt.strftime("%I:%M %p")
|
||||
else:
|
||||
# e.g. "3:01" or "2:22"
|
||||
string = dt.strftime("%I:%M")
|
||||
if string[0] == '0':
|
||||
string = string[1:] # strip leading zeros
|
||||
return string
|
||||
|
||||
# Generate a speakable version of the time
|
||||
speak = ""
|
||||
if use_24hour:
|
||||
if dt.hour == 1:
|
||||
speak += "ein" # 01:00 is "ein Uhr" not "eins Uhr"
|
||||
else:
|
||||
speak += pronounce_number_de(dt.hour)
|
||||
speak += " Uhr"
|
||||
if not dt.minute == 0: # zero minutes are not pronounced, 13:00 is
|
||||
# "13 Uhr" not "13 hundred hours"
|
||||
speak += " " + pronounce_number_de(dt.minute)
|
||||
|
||||
return speak # ampm is ignored when use_24hour is true
|
||||
else:
|
||||
if dt.hour == 0 and dt.minute == 0:
|
||||
return "Mitternacht"
|
||||
elif dt.hour == 12 and dt.minute == 0:
|
||||
return "Mittag"
|
||||
elif dt.minute == 15:
|
||||
# sentence relative to next hour and 0 spoken as 12
|
||||
next_hour = (dt.hour + 1) % 12 or 12
|
||||
speak = "viertel " + pronounce_number_de(next_hour)
|
||||
elif dt.minute == 30:
|
||||
next_hour = (dt.hour + 1) % 12 or 12
|
||||
speak = "halb " + pronounce_number_de(next_hour)
|
||||
elif dt.minute == 45:
|
||||
next_hour = (dt.hour + 1) % 12 or 12
|
||||
speak = "dreiviertel " + pronounce_number_de(next_hour)
|
||||
else:
|
||||
hour = dt.hour % 12 or 12 # 12 hour clock and 0 is spoken as 12
|
||||
if hour == 1: # 01:00 and 13:00 is "ein Uhr" not "eins Uhr"
|
||||
speak += 'ein'
|
||||
else:
|
||||
speak += pronounce_number_de(hour)
|
||||
speak += " Uhr"
|
||||
|
||||
if not dt.minute == 0:
|
||||
speak += " " + pronounce_number_de(dt.minute)
|
||||
|
||||
if use_ampm:
|
||||
if 3 <= dt.hour < 12:
|
||||
speak += " morgens" # 03:00 - 11:59 morgens/in the morning
|
||||
elif 12 <= dt.hour < 18:
|
||||
speak += " nachmittags" # 12:01 - 17:59 nachmittags/afternoon
|
||||
elif 18 <= dt.hour < 22:
|
||||
speak += " abends" # 18:00 - 21:59 abends/evening
|
||||
else:
|
||||
speak += " nachts" # 22:00 - 02:59 nachts/at night
|
||||
|
||||
return speak
|
||||
|
||||
|
||||
def nice_response_de(text):
|
||||
# check for months and call nice_ordinal_de declension of ordinals
|
||||
# replace "^" with "hoch" (to the power of)
|
||||
words = text.split()
|
||||
|
||||
for idx, word in enumerate(words):
|
||||
if word.lower() in months:
|
||||
text = nice_ordinal_de(text)
|
||||
|
||||
if word == '^':
|
||||
wordNext = words[idx + 1] if idx + 1 < len(words) else ""
|
||||
if wordNext.isnumeric():
|
||||
words[idx] = "hoch"
|
||||
text = " ".join(words)
|
||||
return text
|
||||
|
||||
|
||||
def nice_ordinal_de(text):
|
||||
# check for months for declension of ordinals before months
|
||||
# depending on articles/prepositions
|
||||
normalized_text = text
|
||||
words = text.split()
|
||||
|
||||
for idx, word in enumerate(words):
|
||||
wordNext = words[idx + 1] if idx + 1 < len(words) else ""
|
||||
wordPrev = words[idx - 1] if idx > 0 else ""
|
||||
if word[-1:] == ".":
|
||||
if word[:-1].isdecimal():
|
||||
if wordNext.lower() in months:
|
||||
word = pronounce_ordinal_de(int(word[:-1]))
|
||||
if wordPrev.lower() in ["am", "dem", "vom", "zum",
|
||||
"(vom", "(am", "zum"]:
|
||||
word += "n"
|
||||
elif wordPrev.lower() not in ["der", "die", "das"]:
|
||||
word += "r"
|
||||
words[idx] = word
|
||||
normalized_text = " ".join(words)
|
||||
return normalized_text
|
||||
from lingua_franca.lang.format_de import (months, NUM_STRING_DE,
|
||||
NUM_POWERS_OF_TEN,
|
||||
FRACTION_STRING_DE,
|
||||
EXTRA_SPACE,
|
||||
nice_number_de, pronounce_number_de,
|
||||
pronounce_ordinal_de,
|
||||
nice_time_de, nice_response_de,
|
||||
nice_ordinal_de)
|
||||
|
|
|
@ -24,29 +24,29 @@ and to allow localization.
|
|||
|
||||
from difflib import SequenceMatcher
|
||||
from mycroft.util.time import now_local
|
||||
from mycroft.util.lang import get_primary_lang_code
|
||||
from lingua_franca.lang import get_primary_lang_code
|
||||
|
||||
from mycroft.util.lang.parse_en import *
|
||||
from mycroft.util.lang.parse_pt import *
|
||||
from mycroft.util.lang.parse_es import *
|
||||
from mycroft.util.lang.parse_it import *
|
||||
from mycroft.util.lang.parse_sv import *
|
||||
from lingua_franca.lang.parse_en import *
|
||||
from lingua_franca.lang.parse_pt import *
|
||||
from lingua_franca.lang.parse_es import *
|
||||
from lingua_franca.lang.parse_it import *
|
||||
from lingua_franca.lang.parse_sv import *
|
||||
|
||||
from mycroft.util.lang.parse_de import extractnumber_de
|
||||
from mycroft.util.lang.parse_de import extract_numbers_de
|
||||
from mycroft.util.lang.parse_de import extract_datetime_de
|
||||
from mycroft.util.lang.parse_de import normalize_de
|
||||
from mycroft.util.lang.parse_fr import extractnumber_fr
|
||||
from mycroft.util.lang.parse_fr import extract_numbers_fr
|
||||
from mycroft.util.lang.parse_fr import extract_datetime_fr
|
||||
from mycroft.util.lang.parse_fr import normalize_fr
|
||||
from mycroft.util.lang.parse_da import extractnumber_da
|
||||
from mycroft.util.lang.parse_da import extract_numbers_da
|
||||
from mycroft.util.lang.parse_da import extract_datetime_da
|
||||
from mycroft.util.lang.parse_da import normalize_da
|
||||
from mycroft.util.lang.parse_nl import extractnumber_nl
|
||||
from mycroft.util.lang.parse_nl import extract_datetime_nl
|
||||
from mycroft.util.lang.parse_nl import normalize_nl
|
||||
from lingua_franca.lang.parse_de import extractnumber_de
|
||||
from lingua_franca.lang.parse_de import extract_numbers_de
|
||||
from lingua_franca.lang.parse_de import extract_datetime_de
|
||||
from lingua_franca.lang.parse_de import normalize_de
|
||||
from lingua_franca.lang.parse_fr import extractnumber_fr
|
||||
from lingua_franca.lang.parse_fr import extract_numbers_fr
|
||||
from lingua_franca.lang.parse_fr import extract_datetime_fr
|
||||
from lingua_franca.lang.parse_fr import normalize_fr
|
||||
from lingua_franca.lang.parse_da import extractnumber_da
|
||||
from lingua_franca.lang.parse_da import extract_numbers_da
|
||||
from lingua_franca.lang.parse_da import extract_datetime_da
|
||||
from lingua_franca.lang.parse_da import normalize_da
|
||||
from .lang.parse_nl import extractnumber_nl
|
||||
from .lang.parse_nl import extract_datetime_nl
|
||||
from .lang.parse_nl import normalize_nl
|
||||
|
||||
|
||||
from .log import LOG
|
||||
|
|
Loading…
Reference in New Issue