From 530b4bedc73fae9563ee482249a7f5147f3fcda5 Mon Sep 17 00:00:00 2001 From: Andrew Gradinari Date: Thu, 6 Apr 2023 16:13:25 +0100 Subject: [PATCH] [Python][* DateTimeV2] Fix detection of "00:XX" --- .../date_time/base_time.py | 2 +- Specs/DateTime/Dutch/DateTimeModel.json | 24 +++++++++ Specs/DateTime/English/DateTimeExtractor.json | 22 ++++++++ Specs/DateTime/English/DateTimeModel.json | 48 ++++++++++++++++++ Specs/DateTime/English/DateTimeParser.json | 46 +++++++++++++++++ Specs/DateTime/English/TimeExtractor.json | 11 ++++ Specs/DateTime/English/TimeParser.json | 20 ++++++++ .../DateTime/EnglishOthers/DateTimeModel.json | 50 ++++++++++++++++++- Specs/DateTime/French/DateTimeModel.json | 24 +++++++++ Specs/DateTime/Italian/DateTimeModel.json | 24 +++++++++ Specs/DateTime/Portuguese/DateTimeModel.json | 24 +++++++++ Specs/DateTime/Spanish/DateTimeModel.json | 24 +++++++++ 12 files changed, 317 insertions(+), 2 deletions(-) diff --git a/Python/libraries/recognizers-date-time/recognizers_date_time/date_time/base_time.py b/Python/libraries/recognizers-date-time/recognizers_date_time/date_time/base_time.py index b746dc830f..b008bbd6a8 100644 --- a/Python/libraries/recognizers-date-time/recognizers_date_time/date_time/base_time.py +++ b/Python/libraries/recognizers-date-time/recognizers_date_time/date_time/base_time.py @@ -317,7 +317,7 @@ def match_to_time(self, match: Match, reference: datetime): else: hour = int(hour_str) if hour_str.isnumeric( ) else self.config.numbers.get(hour_str, None) - if not hour: + if hour is None: return result # get minute min_str = RegExpUtility.get_group(match, Constants.MINUTE_GROUP_NAME) diff --git a/Specs/DateTime/Dutch/DateTimeModel.json b/Specs/DateTime/Dutch/DateTimeModel.json index a9036f8003..aa2cad2600 100644 --- a/Specs/DateTime/Dutch/DateTimeModel.json +++ b/Specs/DateTime/Dutch/DateTimeModel.json @@ -1610,6 +1610,30 @@ } ] }, + { + "Input": "Ik ben 00:00 terug", + "Context": { + "ReferenceDateTime": "2023-11-07T00:00:00" + }, + "NotSupportedByDesign": "javascript,java", + "Results": [ + { + "Text": "00:00", + "Start": 7, + "End": 11, + "TypeName": "datetimeV2.time", + "Resolution": { + "values": [ + { + "timex": "T00:00", + "type": "time", + "value": "00:00:00" + } + ] + } + } + ] + }, { "Input": "Het is half acht", "Context": { diff --git a/Specs/DateTime/English/DateTimeExtractor.json b/Specs/DateTime/English/DateTimeExtractor.json index e42a7c80de..6c326e8e74 100644 --- a/Specs/DateTime/English/DateTimeExtractor.json +++ b/Specs/DateTime/English/DateTimeExtractor.json @@ -32,6 +32,28 @@ } ] }, + { + "Input": "I'll go back on 15 at 00:00", + "Results": [ + { + "Text": "15 at 00:00", + "Type": "datetime", + "Start": 16, + "Length": 11 + } + ] + }, + { + "Input": "I'll go back on 15 at 00:00:00", + "Results": [ + { + "Text": "15 at 00:00:00", + "Type": "datetime", + "Start": 16, + "Length": 14 + } + ] + }, { "Input": "I'll go back on 15 at 8:00", "Results": [ diff --git a/Specs/DateTime/English/DateTimeModel.json b/Specs/DateTime/English/DateTimeModel.json index 890e324f07..54f9c8fff5 100644 --- a/Specs/DateTime/English/DateTimeModel.json +++ b/Specs/DateTime/English/DateTimeModel.json @@ -10581,6 +10581,54 @@ "NotSupported": "javascript, java, python", "Results": [] }, + { + "Input": "I'll be back at 00:00", + "Context": { + "ReferenceDateTime": "2023-03-28T00:00:00" + }, + "NotSupported": "javascript", + "Results": [ + { + "Text": "00:00", + "Start": 16, + "End": 20, + "TypeName": "datetimeV2.time", + "Resolution": { + "values": [ + { + "timex": "T00:00", + "type": "time", + "value": "00:00:00" + } + ] + } + } + ] + }, + { + "Input": "I'll be back tomorrow at 00:00.", + "Context": { + "ReferenceDateTime": "2023-03-28T00:00:00" + }, + "NotSupported": "javascript", + "Results": [ + { + "Text": "tomorrow at 00:00", + "Start": 13, + "End": 29, + "TypeName": "datetimeV2.datetime", + "Resolution": { + "values": [ + { + "timex": "2023-03-29T00:00", + "type": "datetime", + "value": "2023-03-29 00:00:00" + } + ] + } + } + ] + }, { "Input": "I'll be back at 9:00a.", "Context": { diff --git a/Specs/DateTime/English/DateTimeParser.json b/Specs/DateTime/English/DateTimeParser.json index 2fdd6bd7d7..9d94781207 100644 --- a/Specs/DateTime/English/DateTimeParser.json +++ b/Specs/DateTime/English/DateTimeParser.json @@ -45,6 +45,52 @@ } ] }, + { + "Input": "I'll go back on 15 at 00:00", + "Context": { + "ReferenceDateTime": "2023-11-07T00:00:00" + }, + "Results": [ + { + "Text": "15 at 00:00", + "Type": "datetime", + "Value": { + "Timex": "XXXX-XX-15T00:00", + "FutureResolution": { + "dateTime": "2023-11-15 00:00:00" + }, + "PastResolution": { + "dateTime": "2023-10-15 00:00:00" + } + }, + "Start": 16, + "Length": 11 + } + ] + }, + { + "Input": "I'll go back on 15 at 00:00:00", + "Context": { + "ReferenceDateTime": "2023-11-07T00:00:00" + }, + "Results": [ + { + "Text": "15 at 00:00:00", + "Type": "datetime", + "Value": { + "Timex": "XXXX-XX-15T00:00:00", + "FutureResolution": { + "dateTime": "2023-11-15 00:00:00" + }, + "PastResolution": { + "dateTime": "2023-10-15 00:00:00" + } + }, + "Start": 16, + "Length": 14 + } + ] + }, { "Input": "I'll go back on 15 at 8:00", "Context": { diff --git a/Specs/DateTime/English/TimeExtractor.json b/Specs/DateTime/English/TimeExtractor.json index a5c6e67e2b..538a68fa02 100644 --- a/Specs/DateTime/English/TimeExtractor.json +++ b/Specs/DateTime/English/TimeExtractor.json @@ -120,6 +120,17 @@ } ] }, + { + "Input": "I'll be back 00:00:00", + "Results": [ + { + "Text": "00:00:00", + "Type": "time", + "Start": 13, + "Length": 8 + } + ] + }, { "Input": "I'll be back 00:00:30", "Results": [ diff --git a/Specs/DateTime/English/TimeParser.json b/Specs/DateTime/English/TimeParser.json index c5afe910b3..8e94bcf216 100644 --- a/Specs/DateTime/English/TimeParser.json +++ b/Specs/DateTime/English/TimeParser.json @@ -299,6 +299,26 @@ } ] }, + { + "Input": "I'll be back 00:00", + "Results": [ + { + "Text": "00:00", + "Type": "time", + "Value": { + "Timex": "T00:00", + "FutureResolution": { + "time": "00:00:00" + }, + "PastResolution": { + "time": "00:00:00" + } + }, + "Start": 13, + "Length": 5 + } + ] + }, { "Input": "I'll be back 12:34", "Results": [ diff --git a/Specs/DateTime/EnglishOthers/DateTimeModel.json b/Specs/DateTime/EnglishOthers/DateTimeModel.json index ddc0ec6008..e8a480b33b 100644 --- a/Specs/DateTime/EnglishOthers/DateTimeModel.json +++ b/Specs/DateTime/EnglishOthers/DateTimeModel.json @@ -22,6 +22,30 @@ } ] }, + { + "Input": "I'll go back 5/3/23 @ 00:00:00", + "Context": { + "ReferenceDateTime": "2023-05-01T00:00:00" + }, + "NotSupported": "javascript", + "Results": [ + { + "Text": "5/3/23 @ 00:00:00", + "Start": 13, + "End": 29, + "TypeName": "datetimeV2.datetime", + "Resolution": { + "values": [ + { + "timex": "2023-03-05T00:00:00", + "type": "datetime", + "value": "2023-03-05 00:00:00" + } + ] + } + } + ] + }, { "Input": "The date should be 05-Aug-2016", "Context": { @@ -913,6 +937,30 @@ } ] }, + { + "Input": "The target time is 00:00", + "Context": { + "ReferenceDateTime": "2023-12-26T00:00:00" + }, + "NotSupported": "javascript", + "Results": [ + { + "Text": "00:00", + "Start": 19, + "End": 23, + "TypeName": "datetimeV2.time", + "Resolution": { + "values": [ + { + "timex": "T00:00", + "type": "time", + "value": "00:00:00" + } + ] + } + } + ] + }, { "Input": "I'll go back Sep-23-2020.", "Context": { @@ -1057,4 +1105,4 @@ } ] } -] \ No newline at end of file +] diff --git a/Specs/DateTime/French/DateTimeModel.json b/Specs/DateTime/French/DateTimeModel.json index 971ce15c69..0507dd5f1b 100644 --- a/Specs/DateTime/French/DateTimeModel.json +++ b/Specs/DateTime/French/DateTimeModel.json @@ -1327,6 +1327,30 @@ } ] }, + { + "Input": "Je retournerai 00:00", + "Context": { + "ReferenceDateTime": "2023-11-07T00:00:00" + }, + "NotSupported": "javascript", + "Results": [ + { + "Text": "00:00", + "TypeName": "datetimeV2.time", + "Resolution": { + "values": [ + { + "timex": "T00:00", + "type": "time", + "value": "00:00:00" + } + ] + }, + "Start": 15, + "End": 19 + } + ] + }, { "Input": "Je retournerai 19:56:30", "Context": { diff --git a/Specs/DateTime/Italian/DateTimeModel.json b/Specs/DateTime/Italian/DateTimeModel.json index ce398f9429..b08b77e534 100644 --- a/Specs/DateTime/Italian/DateTimeModel.json +++ b/Specs/DateTime/Italian/DateTimeModel.json @@ -1442,6 +1442,30 @@ } ] }, + { + "Input": "Tornerò alle 00:00", + "Context": { + "ReferenceDateTime": "2016-11-07T00:00:00" + }, + "NotSupportedByDesign": "javascript,java", + "Results": [ + { + "Text": "00:00", + "TypeName": "datetimeV2.time", + "Resolution": { + "values": [ + { + "timex": "T00:00", + "type": "time", + "value": "00:00:00" + } + ] + }, + "Start": 13, + "End": 17 + } + ] + }, { "Input": "Tornerò alle 7:56:30 pm", "Context": { diff --git a/Specs/DateTime/Portuguese/DateTimeModel.json b/Specs/DateTime/Portuguese/DateTimeModel.json index 52eb4a9e82..1517d98ff1 100644 --- a/Specs/DateTime/Portuguese/DateTimeModel.json +++ b/Specs/DateTime/Portuguese/DateTimeModel.json @@ -3001,6 +3001,30 @@ } ] }, + { + "Input": "reunião para 00:00", + "Context": { + "ReferenceDateTime": "2023-05-14T12:00:00" + }, + "NotSupported": "javascript, java", + "Results": [ + { + "Text": "00:00", + "Start": 13, + "End": 17, + "TypeName": "datetimeV2.time", + "Resolution": { + "values": [ + { + "timex": "T00:00", + "type": "time", + "value": "00:00:00" + } + ] + } + } + ] + }, { "Input": "reunião para as 5 e 45", "Context": { diff --git a/Specs/DateTime/Spanish/DateTimeModel.json b/Specs/DateTime/Spanish/DateTimeModel.json index 952961732d..b6f8138df6 100644 --- a/Specs/DateTime/Spanish/DateTimeModel.json +++ b/Specs/DateTime/Spanish/DateTimeModel.json @@ -3083,6 +3083,30 @@ } ] }, + { + "Input": "Regresaré a las 00:00", + "Context": { + "ReferenceDateTime": "2023-11-07T00:00:00" + }, + "NotSupported": "javascript, java", + "Results": [ + { + "Text": "00:00", + "Start": 16, + "End": 20, + "TypeName": "datetimeV2.time", + "Resolution": { + "values": [ + { + "timex": "T00:00", + "type": "time", + "value": "00:00:00" + } + ] + } + } + ] + }, { "Input": "Regresaré a las 7:56:30 de la tarde", "Context": {