Skip to content

Commit

Permalink
[EN DateTime V2] Fixed not all phrases of a form [day abbreviation][n…
Browse files Browse the repository at this point in the history
…umber] (e.g. "Mon 13th") are consistently recognized in .NET (#2803) (#2823)

Co-authored-by: aitelint <[email protected]>
  • Loading branch information
aitelint and aitelint authored Jan 7, 2022
1 parent 04ad38d commit f311d59
Show file tree
Hide file tree
Showing 3 changed files with 205 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ public static class DateTimeDefinitions
public const string UnspecificDatePeriodRegex = @"^(week|fortnight|month|year)$";
public const string PrepositionSuffixRegex = @"\b(on|in|at|around|circa|from|to)$";
public const string FlexibleDayRegex = @"(?<DayOfMonth>([A-Za-z]+\s)?[A-Za-z\d]+)";
public static readonly string ForTheRegex = $@"\b((((?<=for\s+)the\s+{FlexibleDayRegex})|((?<=on\s+)(the\s+)?{FlexibleDayRegex}(?<=(st|nd|rd|th))))(?<end>\s*(,|\.(?!\d)|!|\?|$)))";
public static readonly string ForTheRegex = $@"\b((((?<=\bfor\s+)the\s+{FlexibleDayRegex})|((?<=\bon\s+)(the\s+)?{FlexibleDayRegex}(?<=(st|nd|rd|th))))(?<end>\s*(,|\.(?!\d)|!|\?|$)))";
public static readonly string WeekDayAndDayOfMonthRegex = $@"\b{WeekDayRegex}\s+(the\s+{FlexibleDayRegex})\b";
public static readonly string WeekDayAndDayRegex = $@"\b{WeekDayRegex}\s+(?!(the)){DayRegex}(?!([-:]|(\s+({AmDescRegex}|{PmDescRegex}|{OclockRegex}))))\b";
public const string RestOfDateRegex = @"\b(rest|remaining)\s+(of\s+)?((the|my|this|current)\s+)?(?<duration>week|fortnight|month|year|decade)\b";
Expand Down
2 changes: 1 addition & 1 deletion Patterns/English/English-DateTime.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ PrepositionSuffixRegex: !simpleRegex
FlexibleDayRegex: !simpleRegex
def: (?<DayOfMonth>([A-Za-z]+\s)?[A-Za-z\d]+)
ForTheRegex: !nestedRegex
def: \b((((?<=for\s+)the\s+{FlexibleDayRegex})|((?<=on\s+)(the\s+)?{FlexibleDayRegex}(?<=(st|nd|rd|th))))(?<end>\s*(,|\.(?!\d)|!|\?|$)))
def: \b((((?<=\bfor\s+)the\s+{FlexibleDayRegex})|((?<=\bon\s+)(the\s+)?{FlexibleDayRegex}(?<=(st|nd|rd|th))))(?<end>\s*(,|\.(?!\d)|!|\?|$)))
references: [FlexibleDayRegex]
WeekDayAndDayOfMonthRegex: !nestedRegex
def: \b{WeekDayRegex}\s+(the\s+{FlexibleDayRegex})\b
Expand Down
203 changes: 203 additions & 0 deletions Specs/DateTime/English/DateTimeModel.json
Original file line number Diff line number Diff line change
Expand Up @@ -22505,5 +22505,208 @@
}
}
]
},
{
"Input": "I'll go back Mon 13th",
"Context": {
"ReferenceDateTime": "2022-05-01T00:00:00"
},
"NotSupported": "java, javascript, python",
"Results": [
{
"Text": "mon 13th",
"Start": 13,
"End": 20,
"TypeName": "datetimeV2.date",
"Resolution": {
"values": [
{
"timex": "XXXX-WXX-1",
"type": "date",
"value": "2021-12-13"
},
{
"timex": "XXXX-WXX-1",
"type": "date",
"value": "2022-06-13"
}
]
}
}
]
},
{
"Input": "I'll go back Tue 13th",
"Context": {
"ReferenceDateTime": "2022-05-01T00:00:00"
},
"NotSupported": "java, javascript, python",
"Results": [
{
"Text": "tue 13th",
"Start": 13,
"End": 20,
"TypeName": "datetimeV2.date",
"Resolution": {
"values": [
{
"timex": "XXXX-WXX-2",
"type": "date",
"value": "2021-07-13"
},
{
"timex": "XXXX-WXX-2",
"type": "date",
"value": "2022-09-13"
}
]
}
}
]
},
{
"Input": "I'll go back Wed 13th",
"Context": {
"ReferenceDateTime": "2022-05-01T00:00:00"
},
"NotSupported": "java, javascript, python",
"Results": [
{
"Text": "wed 13th",
"Start": 13,
"End": 20,
"TypeName": "datetimeV2.date",
"Resolution": {
"values": [
{
"timex": "XXXX-WXX-3",
"type": "date",
"value": "2022-04-13"
},
{
"timex": "XXXX-WXX-3",
"type": "date",
"value": "2022-07-13"
}
]
}
}
]
},
{
"Input": "I'll go back Thu 14th",
"Context": {
"ReferenceDateTime": "2022-05-01T00:00:00"
},
"NotSupported": "java, javascript, python",
"Results": [
{
"Text": "thu 14th",
"Start": 13,
"End": 20,
"TypeName": "datetimeV2.date",
"Resolution": {
"values": [
{
"timex": "XXXX-WXX-4",
"type": "date",
"value": "2022-04-14"
},
{
"timex": "XXXX-WXX-4",
"type": "date",
"value": "2022-07-14"
}
]
}
}
]
},
{
"Input": "I'll go back Fri 14th",
"Context": {
"ReferenceDateTime": "2022-05-01T00:00:00"
},
"NotSupported": "java, javascript, python",
"Results": [
{
"Text": "fri 14th",
"Start": 13,
"End": 20,
"TypeName": "datetimeV2.date",
"Resolution": {
"values": [
{
"timex": "XXXX-WXX-5",
"type": "date",
"value": "2022-01-14"
},
{
"timex": "XXXX-WXX-5",
"type": "date",
"value": "2022-10-14"
}
]
}
}
]
},
{
"Input": "I'll go back Sat 14th",
"Context": {
"ReferenceDateTime": "2022-05-01T00:00:00"
},
"NotSupported": "java, javascript, python",
"Results": [
{
"Text": "sat 14th",
"Start": 13,
"End": 20,
"TypeName": "datetimeV2.date",
"Resolution": {
"values": [
{
"timex": "XXXX-WXX-6",
"type": "date",
"value": "2021-08-14"
},
{
"timex": "XXXX-WXX-6",
"type": "date",
"value": "2022-05-14"
}
]
}
}
]
},
{
"Input": "I'll go back Sun 14th",
"Context": {
"ReferenceDateTime": "2022-05-01T00:00:00"
},
"NotSupported": "java, javascript, python",
"Results": [
{
"Text": "sun 14th",
"Start": 13,
"End": 20,
"TypeName": "datetimeV2.date",
"Resolution": {
"values": [
{
"timex": "XXXX-WXX-7",
"type": "date",
"value": "2021-11-14"
},
{
"timex": "XXXX-WXX-7",
"type": "date",
"value": "2022-08-14"
}
]
}
}
]
}
]

0 comments on commit f311d59

Please sign in to comment.