From 257dcb7b21fc1b156c4846a2c3bf24e767f94b7c Mon Sep 17 00:00:00 2001 From: Claudio Klingler Date: Fri, 18 Mar 2022 13:18:14 +0100 Subject: [PATCH] italian: support 'un ora fa', 'un'ora fa', 'oggi alle 11:00'. --- dateparser/data/date_translation_data/it.py | 4 ++++ .../date_translation_data/it.yaml | 3 ++- tests/test_languages.py | 6 ++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/dateparser/data/date_translation_data/it.py b/dateparser/data/date_translation_data/it.py index b6e2735ca..5be5d55b9 100644 --- a/dateparser/data/date_translation_data/it.py +++ b/dateparser/data/date_translation_data/it.py @@ -254,6 +254,7 @@ "skip": [ "circa", "e", + "alle", " ", "'", ",", @@ -277,6 +278,9 @@ "simplifications": [ { "(\\d+)\\s+ora": "\\1 ore" + }, + { + "un[' ]ora": "1 ore" } ] } diff --git a/dateparser_data/supplementary_language_data/date_translation_data/it.yaml b/dateparser_data/supplementary_language_data/date_translation_data/it.yaml index 2babc01f2..1fb744e8f 100644 --- a/dateparser_data/supplementary_language_data/date_translation_data/it.yaml +++ b/dateparser_data/supplementary_language_data/date_translation_data/it.yaml @@ -1,4 +1,4 @@ -skip: ["circa", "e"] +skip: ["circa", "e", "alle"] sentence_splitter_group : 1 @@ -28,3 +28,4 @@ relative-type: simplifications: - (\d+)\s+ora: \1 ore + - un[' ]ora: 1 ore diff --git a/tests/test_languages.py b/tests/test_languages.py index a9d292d8f..4617659df 100644 --- a/tests/test_languages.py +++ b/tests/test_languages.py @@ -72,6 +72,8 @@ def setUp(self): # Italian param('it', "Giovedi Maggio 29 2013", "thursday may 29 2013"), param('it', "19 Luglio 2013", "19 july 2013"), + param('it', "19 Luglio 2013", "19 july 2013"), + # Portuguese param('pt', "22 de dezembro de 2014 às 02:38", "22 december 2014 02:38"), # Russian @@ -848,6 +850,10 @@ def test_translation(self, shortname, datetime_string, expected_translation): param('it', "oggi", "0 day ago"), param('it', "2 settimana fa", "2 week ago"), param('it', "2 anno fa", "2 year ago"), + param('it', "un ora fa", "1 hour ago"), + param('it', "un'ora fa", "1 hour ago"), + param('it', "oggi alle 11:00", "0 day ago 11:00"), + param('it', "oggi 11:00", "0 day ago 11:00"), # Portuguese param('pt', "anteontem", "2 day ago"), param('pt', "ontem", "1 day ago"),