Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Python][EN DateTimeV2] Fix for case like 'March one 2020' #3099

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
73b8241
[ES Temperature] Support informal degrees and fix issue in ES auto-ge…
tellarin Mar 3, 2022
365d66f
[Python] Enabling SpanishMexican culture in Number/Unit/DateTimveV2 (…
colm-dillon Mar 3, 2022
ff11e07
[Python] Add Portuguese support for DateTimeV2 (#2876)
samhickey25 Mar 3, 2022
3e520e5
[KO Number] Fixed incorrect extraction of number from datetime mentio…
aitelint Mar 11, 2022
f703254
[.NET Timexlib] Fix timex-to-string conversion of English ordinals 11…
shana Mar 12, 2022
45b0c3b
[EN .NET] Workaround for TimexProperty.ToString() to not crash on Dat…
shana Mar 14, 2022
d6e3692
Merge pull request #24 from microsoft/master
Mar 30, 2022
30dbdaf
Merge pull request #29 from microsoft/master
Apr 28, 2022
3a2342a
Merge pull request #33 from microsoft/master
samhickey25 May 11, 2022
cd9ba48
Merge pull request #37 from microsoft/master
kevinwalshgen Jun 9, 2022
22f56fd
NLU-2966: Fix failing tests
kevinwalshgen Jun 10, 2022
c544eff
Revert "NLU-2966: Fix failing tests"
kevinwalshgen Jun 10, 2022
8f92c9a
Merge pull request #42 from microsoft/master
samhickey25 Jul 15, 2022
f14677d
Merge branch 'microsoft:master' into master
samhickey25 Aug 8, 2022
d631cbe
Merge branch 'microsoft:master' into master
rbrennangen Aug 15, 2022
a830707
Merge branch 'microsoft:master' into master
rbrennangen Aug 17, 2022
e378aa3
Merge branch 'microsoft:master' into master
rbrennangen Aug 31, 2022
86f14b8
Merge branch 'microsoft:master' into master
Conor-Keaney Nov 10, 2022
4451a53
Merge pull request #53 from microsoft/master
samhickey25 Dec 19, 2022
bde6680
Merge branch 'microsoft:master' into master
Conor-Keaney Jan 30, 2023
b03280c
Merge branch 'microsoft:master' into master
Conor-Keaney Feb 8, 2023
17de6bb
Merge pull request #71 from microsoft/master
samhickey25 Apr 19, 2023
dcc8e88
[EN DateTimeV2] Fix for case like 'March one 2020'
andrew-gradinari Apr 27, 2023
7ed5b55
Mark javascript as unsupported
andrew-gradinari Apr 28, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1417,8 +1417,13 @@ def parse_number_with_month(self, source: str, reference: datetime) -> DateTimeP
if match:
month = self.config.month_of_year.get(match.group())
day = num
suffix = trimmed_source[match.end():]
prefix = trimmed_source[0: match.start()]

prefix_end = min(ers[0].start, match.start())
prefix = trimmed_source[0:prefix_end]

suffix_start = max(ers[0].start + ers[0].length, match.end())
suffix = trimmed_source[suffix_start:]

year = self._get_year_in_affix(suffix, False)

if year == Constants.INVALID_YEAR and self.config.check_both_before_after:
Expand Down Expand Up @@ -1472,7 +1477,7 @@ def parse_number_with_month(self, source: str, reference: datetime) -> DateTimeP
future_date = future_date.replace(year=future_date.year+1)

if past_date >= reference:
past_date = past_date.replace(year=past_date.year+1)
past_date = past_date.replace(year=past_date.year-1)
else:
result.timex = DateTimeFormatUtil.luis_date(year, month, day)

Expand Down
104 changes: 104 additions & 0 deletions Specs/DateTime/English/DateExtractor.json
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,110 @@
}
]
},
{
"Input": "I'll go back on April first 2021.",
"NotSupported": "javascript",
"Results": [
{
"Text": "April first 2021",
"Type": "date",
"Start": 16,
"Length": 16
}
]
},
{
"Input": "I'll go back Jun third 2023",
"NotSupported": "javascript",
"Results": [
{
"Text": "Jun third 2023",
"Type": "date",
"Start": 13,
"Length": 14
}
]
},
{
"Input": "I'll go back September the second 2025.",
"NotSupported": "javascript",
"Results": [
{
"Text": "September the second 2025",
"Type": "date",
"Start": 13,
"Length": 25
}
]
},
{
"Input": "I'll go back March one 2020",
"NotSupported": "javascript",
"Results": [
{
"Text": "March one 2020",
"Type": "date",
"Start": 13,
"Length": 14
}
]
},
{
"Input": "I'll go back Aug twelve 2024.",
"NotSupported": "javascript",
"Results": [
{
"Text": "Aug twelve 2024",
"Type": "date",
"Start": 13,
"Length": 15
}
]
},
{
"Input": "I'll go back February twenty fifth",
"Results": [
{
"Text": "February twenty fifth",
"Type": "date",
"Start": 13,
"Length": 21
}
]
},
{
"Input": "I'll go back on Nov the twelfth.",
"Results": [
{
"Text": "Nov the twelfth",
"Type": "date",
"Start": 16,
"Length": 15
}
]
},
{
"Input": "I'll go back January thirty one",
"Results": [
{
"Text": "January thirty one",
"Type": "date",
"Start": 13,
"Length": 18
}
]
},
{
"Input": "I'll go back Oct twenty three.",
"Results": [
{
"Text": "Oct twenty three",
"Type": "date",
"Start": 13,
"Length": 16
}
]
},
{
"Input": "i went back two months ago",
"Results": [
Expand Down
212 changes: 212 additions & 0 deletions Specs/DateTime/English/DateParser.json
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,218 @@
}
]
},
{
"Input": "I'll go back on April first 2021.",
"Context": {
"ReferenceDateTime": "2023-04-25T00:00:00"
},
"NotSupported": "javascript",
"Results": [
{
"Text": "April first 2021",
"Type": "date",
"Value": {
"Timex": "2021-04-01",
"FutureResolution": {
"date": "2021-04-01"
},
"PastResolution": {
"date": "2021-04-01"
}
},
"Start": 16,
"Length": 16
}
]
},
{
"Input": "I'll go back Jun third 2023",
"Context": {
"ReferenceDateTime": "2023-04-25T00:00:00"
},
"NotSupported": "javascript",
"Results": [
{
"Text": "Jun third 2023",
"Type": "date",
"Value": {
"Timex": "2023-06-03",
"FutureResolution": {
"date": "2023-06-03"
},
"PastResolution": {
"date": "2023-06-03"
}
},
"Start": 13,
"Length": 14
}
]
},
{
"Input": "I'll go back September the second 2025.",
"Context": {
"ReferenceDateTime": "2023-04-25T00:00:00"
},
"NotSupported": "javascript",
"Results": [
{
"Text": "September the second 2025",
"Type": "date",
"Value": {
"Timex": "2025-09-02",
"FutureResolution": {
"date": "2025-09-02"
},
"PastResolution": {
"date": "2025-09-02"
}
},
"Start": 13,
"Length": 25
}
]
},
{
"Input": "I'll go back March one 2020",
"Context": {
"ReferenceDateTime": "2023-04-25T00:00:00"
},
"NotSupported": "javascript",
"Results": [
{
"Text": "March one 2020",
"Type": "date",
"Value": {
"Timex": "2020-03-01",
"FutureResolution": {
"date": "2020-03-01"
},
"PastResolution": {
"date": "2020-03-01"
}
},
"Start": 13,
"Length": 14
}
]
},
{
"Input": "I'll go back Aug twelve 2024.",
"Context": {
"ReferenceDateTime": "2023-04-25T00:00:00"
},
"NotSupported": "javascript",
"Results": [
{
"Text": "Aug twelve 2024",
"Type": "date",
"Value": {
"Timex": "2024-08-12",
"FutureResolution": {
"date": "2024-08-12"
},
"PastResolution": {
"date": "2024-08-12"
}
},
"Start": 13,
"Length": 15
}
]
},
{
"Input": "I'll go back February twenty fifth",
"Context": {
"ReferenceDateTime": "2023-04-25T00:00:00"
},
"Results": [
{
"Text": "February twenty fifth",
"Type": "date",
"Value": {
"Timex": "XXXX-02-25",
"FutureResolution": {
"date": "2024-02-25"
},
"PastResolution": {
"date": "2023-02-25"
}
},
"Start": 13,
"Length": 21
}
]
},
{
"Input": "I'll go back on Nov the twelfth.",
"Context": {
"ReferenceDateTime": "2023-04-25T00:00:00"
},
"Results": [
{
"Text": "Nov the twelfth",
"Type": "date",
"Value": {
"Timex": "XXXX-11-12",
"FutureResolution": {
"date": "2023-11-12"
},
"PastResolution": {
"date": "2022-11-12"
}
},
"Start": 16,
"Length": 15
}
]
},
{
"Input": "I'll go back January thirty one",
"Context": {
"ReferenceDateTime": "2023-04-25T00:00:00"
},
"Results": [
{
"Text": "January thirty one",
"Type": "date",
"Value": {
"Timex": "XXXX-01-31",
"FutureResolution": {
"date": "2024-01-31"
},
"PastResolution": {
"date": "2023-01-31"
}
},
"Start": 13,
"Length": 18
}
]
},
{
"Input": "I'll go back Oct twenty three.",
"Context": {
"ReferenceDateTime": "2023-04-25T00:00:00"
},
"Results": [
{
"Text": "Oct twenty three",
"Type": "date",
"Value": {
"Timex": "XXXX-10-23",
"FutureResolution": {
"date": "2023-10-23"
},
"PastResolution": {
"date": "2022-10-23"
}
},
"Start": 13,
"Length": 16
}
]
},
{
"Input": "I'll go back on Friday",
"Context": {
Expand Down
Loading