diff --git a/.gitignore b/.gitignore index 894a44cc..12b2fa7c 100644 --- a/.gitignore +++ b/.gitignore @@ -102,3 +102,10 @@ venv.bak/ # mypy .mypy_cache/ + +### VisualStudioCode ### +.vscode/* + +### VisualStudioCode Patch ### +# Ignore all local history of files +.history \ No newline at end of file diff --git a/lingua_franca/lang/common_data_es.py b/lingua_franca/lang/common_data_es.py index 64364a4a..0d831ff5 100644 --- a/lingua_franca/lang/common_data_es.py +++ b/lingua_franca/lang/common_data_es.py @@ -20,7 +20,7 @@ from collections import OrderedDict -_ARTICLES = {'el', 'la', 'los', 'las'} +_ARTICLES_ES = {'el', 'la', 'los', 'las'} NUM_STRING_ES = { @@ -41,7 +41,7 @@ 14: 'catorce', 15: 'quince', 16: 'dieciséis', - 17: 'diecisete', + 17: 'diecisiete', 18: 'dieciocho', 19: 'diecinueve', 20: 'veinte', diff --git a/lingua_franca/lang/format_es.py b/lingua_franca/lang/format_es.py index be7d0d19..0979e5aa 100644 --- a/lingua_franca/lang/format_es.py +++ b/lingua_franca/lang/format_es.py @@ -135,9 +135,8 @@ def nice_number_es(number, speech, denominators): else: # else return "2 y 3 cuarto", for example strNumber = '{} y {} {}'.format(whole, num, den_str) - if num > 1 and den != 3: - # if the numerator is greater than 1 and the denominator - # is not 3 ("tercio"), add an s for plural + if num > 1: + # if the numerator is greater than 1 add an s for plural strNumber += 's' return strNumber diff --git a/lingua_franca/lang/parse_es.py b/lingua_franca/lang/parse_es.py index 1cdc7b16..e3c96801 100644 --- a/lingua_franca/lang/parse_es.py +++ b/lingua_franca/lang/parse_es.py @@ -53,8 +53,8 @@ "diecinueve": 19, "veinte": 20, "veintiuno": 21, - u"veintid�s": 22, - u"veintitr�s": 23, + u"veintidós": 22, + u"veintitrés": 23, "veintidos": 22, "veintitres": 23, u"veintitrés": 23, @@ -266,7 +266,7 @@ def es_cte(i, s): def es_number_word(i, mi, ma): if i < len(words): v = es_numbers.get(words[i]) - if v and v >= mi and v <= ma: + if v is not None and v >= mi and v <= ma: return v, i + 1 return None diff --git a/test/test_format_es.py b/test/test_format_es.py index 4fdc4f7c..55b9f9f9 100644 --- a/test/test_format_es.py +++ b/test/test_format_es.py @@ -29,7 +29,7 @@ 0.027: '0,027', 0.5: 'un medio', 1.333: '1 y 1 tercio', - 2.666: '2 y 2 tercio', + 2.666: '2 y 2 tercios', 0.25: 'un cuarto', 1.25: '1 y 1 cuarto', 0.75: '3 cuartos', @@ -106,12 +106,16 @@ def test_convert_int(self): self.assertEqual(pronounce_number(10, lang="es"), "diez") self.assertEqual(pronounce_number(15, lang="es"), "quince") self.assertEqual(pronounce_number(21, lang="es"), "veintiuno") + self.assertEqual(pronounce_number(22, lang="es"), "veintidós") + self.assertEqual(pronounce_number(23, lang="es"), "veintitrés") + self.assertEqual(pronounce_number(26, lang="es"), "veintiséis") self.assertEqual(pronounce_number(27, lang="es"), "veintisiete") self.assertEqual(pronounce_number(30, lang="es"), "treinta") self.assertEqual(pronounce_number(19, lang="es"), "diecinueve") self.assertEqual(pronounce_number(88, lang="es"), "ochenta y ocho") self.assertEqual(pronounce_number(46, lang="es"), "cuarenta y seis") self.assertEqual(pronounce_number(99, lang="es"), "noventa y nueve") + self.assertEqual(pronounce_number(100, lang="es"), "100") def test_convert_negative_int(self): self.assertEqual(pronounce_number(-1, lang="es"), "menos uno") diff --git a/test/test_parse_es.py b/test/test_parse_es.py index cb92e312..80f660a1 100644 --- a/test/test_parse_es.py +++ b/test/test_parse_es.py @@ -39,11 +39,15 @@ def test_numbers_es(self): self.assertEqual(normalize("esto es cuatro cinco seis prueba", lang="es"), "esto es 4 5 6 prueba") - self.assertEqual(normalize(u"siete m�s ocho m�s nueve", lang="es"), - u"7 m�s 8 m�s 9") + self.assertEqual(normalize(u"siete más ocho más nueve", lang="es"), + u"7 más 8 más 9") self.assertEqual(normalize("diez once doce trece catorce quince", lang="es"), "10 11 12 13 14 15") + self.assertEqual(normalize("dos cero uno", lang="es"), + "2 0 1") + self.assertEqual(normalize("hay cero perros", lang="es"), + "hay 0 perros") self.assertEqual(normalize(u"dieciséis diecisiete", lang="es"), "16 17") self.assertEqual(normalize(u"dieciocho diecinueve", lang="es"), @@ -52,13 +56,15 @@ def test_numbers_es(self): "20 30 40") self.assertEqual(normalize(u"treinta y dos caballos", lang="es"), "32 caballos") + self.assertEqual(normalize(u"éramos treinta y algunos caballos", lang="es"), + "éramos 30 y algunos caballos") self.assertEqual(normalize(u"cien caballos", lang="es"), "100 caballos") self.assertEqual(normalize(u"ciento once caballos", lang="es"), "111 caballos") - self.assertEqual(normalize(u"hab�a cuatrocientas una vacas", + self.assertEqual(normalize(u"había cuatrocientas una vacas", lang="es"), - u"hab�a 401 vacas") + u"había 401 vacas") self.assertEqual(normalize(u"dos mil", lang="es"), "2000") self.assertEqual(normalize(u"dos mil trescientas cuarenta y cinco",