Skip to content

Commit 7229305

Browse files
[EN DateTimeV2] Support for [minutes] past [hour] (microsoft#3063)
1 parent 3784fc5 commit 7229305

File tree

7 files changed

+230
-4
lines changed

7 files changed

+230
-4
lines changed

.NET/Microsoft.Recognizers.Definitions.Common/English/DateTimeDefinitions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ public static class DateTimeDefinitions
160160
public const string LunchRegex = @"\blunchtime\b";
161161
public const string NightRegex = @"\b(mid)?night\b";
162162
public const string CommonDatePrefixRegex = @"^[\.]";
163-
public static readonly string LessThanOneHour = $@"(?<lth>(a\s+)?quarter|three quarter(s)?|half( an hour)?|{BaseDateTime.DeltaMinuteRegex}(\s+(minutes?|mins?))|{DeltaMinuteNumRegex}(\s+(minutes?|mins?)))";
163+
public static readonly string LessThanOneHour = $@"(?<lth>(a\s+)?quarter|three quarter(s)?|half( an hour)?|{BaseDateTime.DeltaMinuteRegex}(\s+(minutes?|mins?)|(?=\s+past))|{DeltaMinuteNumRegex}(\s+(minutes?|mins?)|(?=\s+past)))";
164164
public static readonly string WrittenTimeRegex = $@"(?<writtentime>{HourNumRegex}\s+{MinuteNumRegex}(\s+(minutes?|mins?))?)";
165165
public static readonly string TimePrefix = $@"(?<prefix>{LessThanOneHour}\s+(past|to))";
166166
public static readonly string TimeSuffix = $@"(?<suffix>{AmRegex}|{PmRegex}|{OclockRegex})";

Java/libraries/recognizers-text-date-time/src/main/java/com/microsoft/recognizers/text/datetime/resources/EnglishDateTime.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ public class EnglishDateTime {
486486

487487
public static final String CommonDatePrefixRegex = "^[\\.]";
488488

489-
public static final String LessThanOneHour = "(?<lth>(a\\s+)?quarter|three quarter(s)?|half( an hour)?|{BaseDateTime.DeltaMinuteRegex}(\\s+(minutes?|mins?))|{DeltaMinuteNumRegex}(\\s+(minutes?|mins?)))"
489+
public static final String LessThanOneHour = "(?<lth>(a\\s+)?quarter|three quarter(s)?|half( an hour)?|{BaseDateTime.DeltaMinuteRegex}(\\s+(minutes?|mins?)|(?=\\s+past))|{DeltaMinuteNumRegex}(\\s+(minutes?|mins?)|(?=\\s+past)))"
490490
.replace("{BaseDateTime.DeltaMinuteRegex}", BaseDateTime.DeltaMinuteRegex)
491491
.replace("{DeltaMinuteNumRegex}", DeltaMinuteNumRegex);
492492

JavaScript/packages/recognizers-date-time/src/resources/englishDateTime.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ export namespace EnglishDateTime {
150150
export const LunchRegex = `\\blunchtime\\b`;
151151
export const NightRegex = `\\b(mid)?night\\b`;
152152
export const CommonDatePrefixRegex = `^[\\.]`;
153-
export const LessThanOneHour = `(?<lth>(a\\s+)?quarter|three quarter(s)?|half( an hour)?|${BaseDateTime.DeltaMinuteRegex}(\\s+(minutes?|mins?))|${DeltaMinuteNumRegex}(\\s+(minutes?|mins?)))`;
153+
export const LessThanOneHour = `(?<lth>(a\\s+)?quarter|three quarter(s)?|half( an hour)?|${BaseDateTime.DeltaMinuteRegex}(\\s+(minutes?|mins?)|(?=\\s+past))|${DeltaMinuteNumRegex}(\\s+(minutes?|mins?)|(?=\\s+past)))`;
154154
export const WrittenTimeRegex = `(?<writtentime>${HourNumRegex}\\s+${MinuteNumRegex}(\\s+(minutes?|mins?))?)`;
155155
export const TimePrefix = `(?<prefix>${LessThanOneHour}\\s+(past|to))`;
156156
export const TimeSuffix = `(?<suffix>${AmRegex}|${PmRegex}|${OclockRegex})`;

Patterns/English/English-DateTime.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ NightRegex: !simpleRegex
362362
CommonDatePrefixRegex: !simpleRegex
363363
def: ^[\.]
364364
LessThanOneHour: !nestedRegex
365-
def: (?<lth>(a\s+)?quarter|three quarter(s)?|half( an hour)?|{BaseDateTime.DeltaMinuteRegex}(\s+(minutes?|mins?))|{DeltaMinuteNumRegex}(\s+(minutes?|mins?)))
365+
def: (?<lth>(a\s+)?quarter|three quarter(s)?|half( an hour)?|{BaseDateTime.DeltaMinuteRegex}(\s+(minutes?|mins?)|(?=\s+past))|{DeltaMinuteNumRegex}(\s+(minutes?|mins?)|(?=\s+past)))
366366
references: [ BaseDateTime.DeltaMinuteRegex, DeltaMinuteNumRegex ]
367367
WrittenTimeRegex: !nestedRegex
368368
def: (?<writtentime>{HourNumRegex}\s+{MinuteNumRegex}(\s+(minutes?|mins?))?)

Specs/DateTime/English/DateTimeModel.json

+102
Original file line numberDiff line numberDiff line change
@@ -25748,5 +25748,107 @@
2574825748
}
2574925749
}
2575025750
]
25751+
},
25752+
{
25753+
"Input": "I made this purchase at 10 past 9",
25754+
"Context": {
25755+
"ReferenceDateTime": "2023-03-01T00:00:00"
25756+
},
25757+
"Results": [
25758+
{
25759+
"Text": "10 past 9",
25760+
"Start": 24,
25761+
"End": 32,
25762+
"TypeName": "datetimeV2.time",
25763+
"Resolution": {
25764+
"values": [
25765+
{
25766+
"timex": "T09:10",
25767+
"type": "time",
25768+
"value": "09:10:00"
25769+
},
25770+
{
25771+
"timex": "T21:10",
25772+
"type": "time",
25773+
"value": "21:10:00"
25774+
}
25775+
]
25776+
}
25777+
}
25778+
]
25779+
},
25780+
{
25781+
"Input": "It's 15 past seven o'clock",
25782+
"Context": {
25783+
"ReferenceDateTime": "2023-03-01T00:00:00"
25784+
},
25785+
"Results": [
25786+
{
25787+
"Text": "15 past seven o'clock",
25788+
"Start": 5,
25789+
"End": 25,
25790+
"TypeName": "datetimeV2.time",
25791+
"Resolution": {
25792+
"values": [
25793+
{
25794+
"timex": "T07:15",
25795+
"type": "time",
25796+
"value": "07:15:00"
25797+
},
25798+
{
25799+
"timex": "T19:15",
25800+
"type": "time",
25801+
"value": "19:15:00"
25802+
}
25803+
]
25804+
}
25805+
}
25806+
]
25807+
},
25808+
{
25809+
"Input": "I made this purchase at ten past 9 in the evening",
25810+
"Context": {
25811+
"ReferenceDateTime": "2023-03-01T00:00:00"
25812+
},
25813+
"Results": [
25814+
{
25815+
"Text": "ten past 9 in the evening",
25816+
"Start": 24,
25817+
"End": 48,
25818+
"TypeName": "datetimeV2.time",
25819+
"Resolution": {
25820+
"values": [
25821+
{
25822+
"timex": "T21:10",
25823+
"type": "time",
25824+
"value": "21:10:00"
25825+
}
25826+
]
25827+
}
25828+
}
25829+
]
25830+
},
25831+
{
25832+
"Input": "It's fifteen past eight in the morning",
25833+
"Context": {
25834+
"ReferenceDateTime": "2023-03-01T00:00:00"
25835+
},
25836+
"Results": [
25837+
{
25838+
"Text": "fifteen past eight in the morning",
25839+
"Start": 5,
25840+
"End": 37,
25841+
"TypeName": "datetimeV2.time",
25842+
"Resolution": {
25843+
"values": [
25844+
{
25845+
"timex": "T08:15",
25846+
"type": "time",
25847+
"value": "08:15:00"
25848+
}
25849+
]
25850+
}
25851+
}
25852+
]
2575125853
}
2575225854
]

Specs/DateTime/English/TimeExtractor.json

+44
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,50 @@
307307
}
308308
]
309309
},
310+
{
311+
"Input": "I made this purchase at 10 past 9",
312+
"Results": [
313+
{
314+
"Text": "10 past 9",
315+
"Type": "time",
316+
"Start": 24,
317+
"Length": 9
318+
}
319+
]
320+
},
321+
{
322+
"Input": "It's 15 past seven o'clock",
323+
"Results": [
324+
{
325+
"Text": "15 past seven o'clock",
326+
"Type": "time",
327+
"Start": 5,
328+
"Length": 21
329+
}
330+
]
331+
},
332+
{
333+
"Input": "I made this purchase at ten past 9 in the evening",
334+
"Results": [
335+
{
336+
"Text": "ten past 9 in the evening",
337+
"Type": "time",
338+
"Start": 24,
339+
"Length": 25
340+
}
341+
]
342+
},
343+
{
344+
"Input": "It's fifteen past eight in the morning",
345+
"Results": [
346+
{
347+
"Text": "fifteen past eight in the morning",
348+
"Type": "time",
349+
"Start": 5,
350+
"Length": 33
351+
}
352+
]
353+
},
310354
{
311355
"Input": "I'll be back in the afternoon at 7",
312356
"Results": [

Specs/DateTime/English/TimeParser.json

+80
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,86 @@
659659
}
660660
]
661661
},
662+
{
663+
"Input": "I made this purchase at 10 past 9",
664+
"Results": [
665+
{
666+
"Text": "10 past 9",
667+
"Type": "time",
668+
"Value": {
669+
"Timex": "T09:10",
670+
"FutureResolution": {
671+
"time": "09:10:00"
672+
},
673+
"PastResolution": {
674+
"time": "09:10:00"
675+
}
676+
},
677+
"Start": 24,
678+
"Length": 9
679+
}
680+
]
681+
},
682+
{
683+
"Input": "It's 15 past seven o'clock",
684+
"Results": [
685+
{
686+
"Text": "15 past seven o'clock",
687+
"Type": "time",
688+
"Value": {
689+
"Timex": "T07:15",
690+
"FutureResolution": {
691+
"time": "07:15:00"
692+
},
693+
"PastResolution": {
694+
"time": "07:15:00"
695+
}
696+
},
697+
"Start": 5,
698+
"Length": 21
699+
}
700+
]
701+
},
702+
{
703+
"Input": "I made this purchase at ten past 9 in the evening",
704+
"Results": [
705+
{
706+
"Text": "ten past 9 in the evening",
707+
"Type": "time",
708+
"Value": {
709+
"Timex": "T21:10",
710+
"FutureResolution": {
711+
"time": "21:10:00"
712+
},
713+
"PastResolution": {
714+
"time": "21:10:00"
715+
}
716+
},
717+
"Start": 24,
718+
"Length": 25
719+
}
720+
]
721+
},
722+
{
723+
"Input": "It's fifteen past eight in the morning",
724+
"Results": [
725+
{
726+
"Text": "fifteen past eight in the morning",
727+
"Type": "time",
728+
"Value": {
729+
"Timex": "T08:15",
730+
"FutureResolution": {
731+
"time": "08:15:00"
732+
},
733+
"PastResolution": {
734+
"time": "08:15:00"
735+
}
736+
},
737+
"Start": 5,
738+
"Length": 33
739+
}
740+
]
741+
},
662742
{
663743
"Input": "I'll be back in the afternoon at 7",
664744
"Results": [

0 commit comments

Comments
 (0)