Fix some number ranges were wrongly extracted as datetime ranges#1033
Closed
WujiaShi wants to merge 5 commits intomicrosoft:masterfrom
Closed
Fix some number ranges were wrongly extracted as datetime ranges#1033WujiaShi wants to merge 5 commits intomicrosoft:masterfrom
WujiaShi wants to merge 5 commits intomicrosoft:masterfrom
Conversation
# Conflicts: # .NET/Microsoft.Recognizers.Definitions/English/DateTimeDefinitions.cs # Patterns/English/English-DateTime.yaml # Python/libraries/recognizers-date-time/recognizers_date_time/resources/english_date_time.py # Specs/DateTime/English/DateTimeModel.json # Specs/DateTime/English/DateTimeModelComplexCalendar.json # Specs/DateTime/English/DateTimeModelExperimentalMode.json
tellarin
requested changes
Dec 7, 2018
| export const ImplicitDayRegex = `(the\\s*)?(?<day>10th|11th|11st|12nd|12th|13rd|13th|14th|15th|16th|17th|18th|19th|1st|20th|21st|21th|22nd|22th|23rd|23th|24th|25th|26th|27th|28th|29th|2nd|30th|31st|3rd|4th|5th|6th|7th|8th|9th)\\b`; | ||
| export const MonthNumRegex = `(?<month>01|02|03|04|05|06|07|08|09|10|11|12|1|2|3|4|5|6|7|8|9)\\b`; | ||
| export const CenturyRegex = `\\b(?<century>((one|two)\\s+thousand(\\s+and)?(\\s+(one|two|three|four|five|six|seven|eight|nine)\\s+hundred(\\s+and)?)?)|((twenty one|twenty two|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen|twenty)(\\s+hundred)?(\\s+and)?))\\b`; | ||
| export const CenturyPhraseEndRegex = `\\b(?<century>((one|two)\\s+thousand(\\s+and)?(\\s+(one|two|three|four|five|six|seven|eight|nine)\\s+hundred(\\s+and)?)?)|((twenty one|twenty two|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen|twenty)(\\s+hundred)+(\\s+and)?))\\b`; |
Collaborator
There was a problem hiding this comment.
This duplication of regex seems strange. It would be better to re-write or break down CenturyRegex and FullTextYearRegex.
| "ReferenceDateTime": "2018-12-05T12:00:00" | ||
| }, | ||
| "NotSupportedByDesign": "java", | ||
| "Results":[ |
Collaborator
There was a problem hiding this comment.
This is incorrect. "May" here should not be considered a daterange. If we want to add a spec, it should be for the correct behaviour.
So here there are two alternatives. Either we can keep this spec, but the result is [] and mark it as NotSupported for now. Or the PR should fix the "may" false positive and also the spec expected result.
Collaborator
|
I see you've pushed a new version as #1044. I'll close this one then. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix some number ranges were wrongly extracted as datetime ranges, like "one may", "twenty-one", "two to four". This issue is due to CenturyRegex has little constraints.
In order to filter out those cases, a new regex "CenturyPhraseEndRegex" was added. The mechanism behind this is if a simple number ( eg. twenty) in the middle of sentences, we consider it is possible to be a datetime range.
However, when it at the end of a phrase, it must be followed by another number (eg. thousand, hundred, etc) and cannot be recognized as a datetime range by itself.