insert test and cleanup

specific test for  short_scale=True
pull/1912/head
Ale 2019-01-03 18:16:09 +01:00 committed by GitHub
parent a6eff4c750
commit 3fc29e0e96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 96 additions and 93 deletions

View File

@ -28,28 +28,28 @@ class TestNormalize(unittest.TestCase):
Test cases for Italian parsing
"""
def test_articles_it(self):
self.assertEqual(normalize(u"questo è il test",
self.assertEqual(normalize("questo è il test",
lang="it", remove_articles=True),
u"questo è test")
self.assertEqual(normalize(u"questa è la frase",
"questo è test")
self.assertEqual(normalize("questa è la frase",
lang="it", remove_articles=True),
u"questa è frase")
self.assertEqual(normalize(u"questo è lo scopo", lang="it",
"questa è frase")
self.assertEqual(normalize("questo è lo scopo", lang="it",
remove_articles=True),
u"questo è scopo")
self.assertEqual(normalize(u"questo è il test extra",
"questo è scopo")
self.assertEqual(normalize("questo è il test extra",
lang="it", remove_articles=False),
u"questo è il test extra")
"questo è il test extra")
def test_extractnumber_it(self):
self.assertEqual(extract_number(u"questo è il primo test",
self.assertEqual(extract_number("questo è il primo test",
lang="it"), 1)
self.assertEqual(extract_number(u"questo è il 2 test", lang="it"), 2)
self.assertEqual(extract_number(u"questo è il secondo test",
self.assertEqual(extract_number("questo è il 2 test", lang="it"), 2)
self.assertEqual(extract_number("questo è il secondo test",
lang="it"), 2)
self.assertEqual(extract_number(u"questo è un terzo di test",
self.assertEqual(extract_number("questo è un terzo di test",
lang="it"), 1.0 / 3.0)
self.assertEqual(extract_number(u"questo è test numero 4", lang="it"),
self.assertEqual(extract_number("questo è test numero 4", lang="it"),
4)
self.assertEqual(extract_number("un terzo di tazza", lang="it"),
1.0 / 3.0)
@ -79,6 +79,9 @@ class TestNormalize(unittest.TestCase):
lang="it"), 7.008)
self.assertEqual(extract_number("venti tredicesimi",
lang="it"), 20.0 / 13.0)
self.assertEqual(extract_number("venti tredicesimi",
lang="it", short_scale=True),
20.0 / 13.0)
self.assertEqual(extract_number("sei virgola sessanta sei",
lang="it"), 6.66)
self.assertEqual(extract_number("sei virgola sessantasei",
@ -121,23 +124,23 @@ class TestNormalize(unittest.TestCase):
lang="it"), False)
def test_spaces_it(self):
self.assertEqual(normalize(u"questo e' il test",
lang="it"), u"questo e' test")
self.assertEqual(normalize(u"questo è un test ",
lang="it"), u"questo è 1 test")
self.assertEqual(normalize(u"un altro test ",
lang="it"), u"1 altro test")
self.assertEqual(normalize(u"questa è un' altra amica ", lang="it",
self.assertEqual(normalize("questo e' il test",
lang="it"), "questo e' test")
self.assertEqual(normalize("questo è un test ",
lang="it"), "questo è 1 test")
self.assertEqual(normalize("un altro test ",
lang="it"), "1 altro test")
self.assertEqual(normalize("questa è un' altra amica ", lang="it",
remove_articles=False),
u"questa è 1 altra amica")
self.assertEqual(normalize(u"questo è un test ", lang="it",
remove_articles=False), u"questo è 1 test")
"questa è 1 altra amica")
self.assertEqual(normalize("questo è un test ", lang="it",
remove_articles=False), "questo è 1 test")
def test_numbers_it(self):
self.assertEqual(normalize(u"questo è il test uno due tre",
lang="it"), u"questo è test 1 2 3")
self.assertEqual(normalize(u"è un test sette otto nove",
lang="it"), u"è 1 test 7 8 9")
self.assertEqual(normalize("questo è il test uno due tre",
lang="it"), "questo è test 1 2 3")
self.assertEqual(normalize("è un test sette otto nove",
lang="it"), "è 1 test 7 8 9")
self.assertEqual(normalize("test zero dieci undici dodici tredici",
lang="it"), "test 0 10 11 12 13")
self.assertEqual(normalize("test mille seicento sessanta e sei",
@ -169,98 +172,98 @@ class TestNormalize(unittest.TestCase):
self.assertEqual(res[0], expected_date)
self.assertEqual(res[1], expected_leftover)
testExtract(u"quale giorno è oggi",
"2018-01-13 00:00:00", u"quale giorno")
testExtract(u"che giorno è domani",
"2018-01-14 00:00:00", u"che giorno")
testExtract(u"che giorno era ieri",
"2018-01-12 00:00:00", u"che giorno")
testExtract(u"che giorno è dopo domani",
"2018-01-15 00:00:00", u"che giorno")
testExtract(u"fissare la cena tra 5 giorni",
"2018-01-18 00:00:00", u"fissare cena")
testExtract(u"Come è il tempo per dopodomani",
"2018-01-15 00:00:00", u"come tempo")
testExtract(u"ricordami alle 22:45",
"2018-01-13 22:45:00", u"ricordami")
testExtract(u"Come è il tempo venerdì mattina",
testExtract("quale giorno è oggi",
"2018-01-13 00:00:00", "quale giorno")
testExtract("che giorno è domani",
"2018-01-14 00:00:00", "che giorno")
testExtract("che giorno era ieri",
"2018-01-12 00:00:00", "che giorno")
testExtract("che giorno è dopo domani",
"2018-01-15 00:00:00", "che giorno")
testExtract("fissare la cena tra 5 giorni",
"2018-01-18 00:00:00", "fissare cena")
testExtract("Come è il tempo per dopodomani",
"2018-01-15 00:00:00", "come tempo")
testExtract("ricordami alle 22:45",
"2018-01-13 22:45:00", "ricordami")
testExtract("Come è il tempo venerdì mattina",
"2018-01-19 08:00:00", "come tempo")
testExtract(u"Ricordami di chiamare la mamma"
u" in 8 settimane e 2 giorni.",
"2018-03-12 00:00:00", u"ricordami chiamare mamma")
testExtract(u"Gioca a briscola 2 giorni dopo venerdì",
"2018-01-21 00:00:00", u"gioca briscola")
testExtract(u"Inizia le pulizie alle 15:45 di giovedì",
"2018-01-18 15:45:00", u"inizia pulizie")
testExtract("Ricordami di chiamare la mamma"
" in 8 settimane e 2 giorni.",
"2018-03-12 00:00:00", "ricordami chiamare mamma")
testExtract("Gioca a briscola 2 giorni dopo venerdì",
"2018-01-21 00:00:00", "gioca briscola")
testExtract("Inizia le pulizie alle 15:45 di giovedì",
"2018-01-18 15:45:00", "inizia pulizie")
testExtract("lunedi compra formaggio",
"2018-01-15 00:00:00", u"compra formaggio")
"2018-01-15 00:00:00", "compra formaggio")
testExtract("suona musica compleanno tra 5 anni da oggi",
"2023-01-13 00:00:00", "suona musica compleanno")
testExtract(u"Invia Skype alla mamma alle 12:45 di giovedì prossimo.",
"2018-01-18 12:45:00", u"invia skype mamma")
testExtract(u"Come è il tempo questo venerdì?",
"2018-01-19 00:00:00", u"come tempo")
testExtract(u"Come è il tempo questo venerdì pomeriggio?",
"2018-01-19 15:00:00", u"come tempo")
testExtract(u"Come è il tempo questo venerdì a mezza notte?",
"2018-01-20 00:00:00", u"come tempo")
testExtract(u"Come è il tempo questo venerdì a mezzogiorno?",
testExtract("Invia Skype alla mamma alle 12:45 di giovedì prossimo.",
"2018-01-18 12:45:00", "invia skype mamma")
testExtract("Come è il tempo questo venerdì?",
"2018-01-19 00:00:00", "come tempo")
testExtract("Come è il tempo questo venerdì pomeriggio?",
"2018-01-19 15:00:00", "come tempo")
testExtract("Come è il tempo questo venerdì a mezza notte?",
"2018-01-20 00:00:00", "come tempo")
testExtract("Come è il tempo questo venerdì a mezzogiorno?",
"2018-01-19 12:00:00", "come tempo")
testExtract(u"Come è il tempo questo venerdì alle 11 del mattino?",
testExtract("Come è il tempo questo venerdì alle 11 del mattino?",
"2018-01-19 11:00:00", "come tempo")
testExtract("Ricordami di chiamare mia madre il 3 agosto.",
"2018-08-03 00:00:00", "ricordami chiamare mia madre")
testExtract(u"comprare fragole il 13 maggio",
testExtract("comprare fragole il 13 maggio",
"2018-05-13 00:00:00", "comprare fragole")
testExtract(u"fare acquisti il 13 maggio",
testExtract("fare acquisti il 13 maggio",
"2018-05-13 00:00:00", "fare acquisti")
testExtract(u"compra le candele il 1° maggio",
testExtract("compra le candele il 1° maggio",
"2018-05-01 00:00:00", "compra candele")
testExtract(u"bere birra il 13 maggio",
testExtract("bere birra il 13 maggio",
"2018-05-13 00:00:00", "bere birra")
testExtract(u"Come è il tempo 1 giorno dopo domani?",
testExtract("Come è il tempo 1 giorno dopo domani?",
"2018-01-15 00:00:00", "come tempo")
testExtract(u"Come è il tempo alle ore 0700?",
testExtract("Come è il tempo alle ore 0700?",
"2018-01-13 07:00:00", "come tempo ora")
testExtract(u"Come è il tempo domani alle 7 in punto?",
testExtract("Come è il tempo domani alle 7 in punto?",
"2018-01-14 07:00:00", "come tempo")
testExtract(u"Come è il tempo domani alle 2 del pomeriggio",
testExtract("Come è il tempo domani alle 2 del pomeriggio",
"2018-01-14 14:00:00", "come tempo")
testExtract(u"Come è il tempo domani pomeriggio alle 2",
testExtract("Come è il tempo domani pomeriggio alle 2",
"2018-01-14 14:00:00", "come tempo")
testExtract(u"Come è il tempo domani per le 2:00",
testExtract("Come è il tempo domani per le 2:00",
"2018-01-14 02:00:00", "come tempo")
testExtract(u"Come è il tempo alle 2 del pomeriggio di \
testExtract("Come è il tempo alle 2 del pomeriggio di \
venerdì prossimo?",
"2018-01-19 14:00:00", u"come tempo")
testExtract(u"Ricordami di svegliarmi tra 4 anni",
"2022-01-13 00:00:00", u"ricordami svegliarmi")
testExtract(u"Ricordami di svegliarmi tra 4 anni e 4 giorni",
"2022-01-17 00:00:00", u"ricordami svegliarmi")
testExtract(u"Dormi 3 giorni da domani.",
"2018-01-17 00:00:00", u"dormi")
testExtract(u"segna appuntamento tra 2 settimane e 6 giorni \
"2018-01-19 14:00:00", "come tempo")
testExtract("Ricordami di svegliarmi tra 4 anni",
"2022-01-13 00:00:00", "ricordami svegliarmi")
testExtract("Ricordami di svegliarmi tra 4 anni e 4 giorni",
"2022-01-17 00:00:00", "ricordami svegliarmi")
testExtract("Dormi 3 giorni da domani.",
"2018-01-17 00:00:00", "dormi")
testExtract("segna appuntamento tra 2 settimane e 6 giorni \
dopo sabato",
"2018-02-02 00:00:00", u"segna appuntamento")
testExtract(u"La festa inizia alle 8 di sera di giovedì",
"2018-01-18 20:00:00", u"la festa inizia")
testExtract(u"Come è il meteo 3 tra giorni?",
"2018-01-16 00:00:00", u"come meteo")
testExtract(u"fissa appuntamento dicembre 3",
"2018-02-02 00:00:00", "segna appuntamento")
testExtract("La festa inizia alle 8 di sera di giovedì",
"2018-01-18 20:00:00", "la festa inizia")
testExtract("Come è il meteo 3 tra giorni?",
"2018-01-16 00:00:00", "come meteo")
testExtract("fissa appuntamento dicembre 3",
"2018-12-03 00:00:00", "fissa appuntamento")
testExtract(u"incontriamoci questa sera alle 8 ",
testExtract("incontriamoci questa sera alle 8 ",
"2018-01-13 20:00:00", "incontriamoci")
testExtract(u"incontriamoci alle 8 questa sera",
testExtract("incontriamoci alle 8 questa sera",
"2018-01-13 20:00:00", "incontriamoci")
testExtract(u"impostare sveglia questa sera alle 9 ",
testExtract("impostare sveglia questa sera alle 9 ",
"2018-01-13 21:00:00", "impostare sveglia")
testExtract(u"impostare sveglia questa sera alle 21 ",
testExtract("impostare sveglia questa sera alle 21 ",
"2018-01-13 21:00:00", "impostare sveglia")
testExtract(u"inserire appuntamento domani sera alle 23",
testExtract("inserire appuntamento domani sera alle 23",
"2018-01-14 23:00:00", "inserire appuntamento")
testExtract(u"inserire appuntamento domani alle 9 e mezza",
testExtract("inserire appuntamento domani alle 9 e mezza",
"2018-01-14 09:30:00", "inserire appuntamento")
testExtract(u"inserire appuntamento domani sera alle 23 e 3 quarti",
testExtract("inserire appuntamento domani sera alle 23 e 3 quarti",
"2018-01-14 23:45:00", "inserire appuntamento")
def test_extractdatetime_default_it(self):
@ -282,7 +285,7 @@ class TestNormalize(unittest.TestCase):
self.assertEqual(get_gender("uomini", "questi uomini mangiano pasta",
lang="it"), "m")
self.assertEqual(get_gender("ponte", "il ponte", lang="it"), "m")
self.assertEqual(get_gender("ponte", u"questo ponte è caduto",
self.assertEqual(get_gender("ponte", "questo ponte è caduto",
lang="it"), "m")
self.assertEqual(get_gender("scultrice", "questa scultrice famosa",
lang="it"), "f")