diff --git a/.NET/Microsoft.Recognizers.Definitions.Common/English/DateTimeDefinitions.cs b/.NET/Microsoft.Recognizers.Definitions.Common/English/DateTimeDefinitions.cs index d96bb84eae..22608f8e73 100644 --- a/.NET/Microsoft.Recognizers.Definitions.Common/English/DateTimeDefinitions.cs +++ b/.NET/Microsoft.Recognizers.Definitions.Common/English/DateTimeDefinitions.cs @@ -692,10 +692,11 @@ public static class DateTimeDefinitions public static readonly string[] DurationDateRestrictions = { @"today", @"now" }; public static readonly Dictionary AmbiguityFiltersDict = new Dictionary { - { @"\bmorning|afternoon|evening|night|day\b", @"\b(good\s+(morning|afternoon|evening|night|day))|(nighty\s+night)\b" }, + { @"^(morning|afternoon|evening|night|day)\b", @"\b(good\s+(morning|afternoon|evening|night|day))|(nighty\s+night)\b" }, { @"\bnow\b", @"\b(^now,)|\b((is|are)\s+now\s+for|for\s+now)\b" }, { @"\bmay\b", @"\b((((!|\.|\?|,|;|)\s+|^)may i)|(i|you|he|she|we|they)\s+may|(may\s+((((also|not|(also not)|well)\s+)?(be|ask|contain|constitute|e-?mail|take|have|result|involve|get|work|reply|differ))|(or may not))))\b" }, - { @"\b(a|one) second\b", @"\b(? MorningTermList = new List { diff --git a/.NET/Microsoft.Recognizers.Text.DateTime/Constants.cs b/.NET/Microsoft.Recognizers.Text.DateTime/Constants.cs index 86ffbe3bdd..62e2ce009e 100644 --- a/.NET/Microsoft.Recognizers.Text.DateTime/Constants.cs +++ b/.NET/Microsoft.Recognizers.Text.DateTime/Constants.cs @@ -128,6 +128,7 @@ public static class Constants public const string BusinessDayGroupName = "business"; public const string LeftAmPmGroupName = "leftDesc"; public const string RightAmPmGroupName = "rightDesc"; + public const string MealTimeGroupName = "mealTime"; public const string DECADE_UNIT = "10Y"; public const string FORTNIGHT_UNIT = "2W"; diff --git a/.NET/Microsoft.Recognizers.Text.DateTime/Extractors/BaseDateTimePeriodExtractor.cs b/.NET/Microsoft.Recognizers.Text.DateTime/Extractors/BaseDateTimePeriodExtractor.cs index e5f2191817..2baf0b53f2 100644 --- a/.NET/Microsoft.Recognizers.Text.DateTime/Extractors/BaseDateTimePeriodExtractor.cs +++ b/.NET/Microsoft.Recognizers.Text.DateTime/Extractors/BaseDateTimePeriodExtractor.cs @@ -312,7 +312,15 @@ private List MergeTwoTimePoints(string text, DateObject reference, List x.Start).ToList(); diff --git a/.NET/Microsoft.Recognizers.Text.DateTime/Extractors/BaseMergedDateTimeExtractor.cs b/.NET/Microsoft.Recognizers.Text.DateTime/Extractors/BaseMergedDateTimeExtractor.cs index 0e276bb3a5..af0bf91ac9 100644 --- a/.NET/Microsoft.Recognizers.Text.DateTime/Extractors/BaseMergedDateTimeExtractor.cs +++ b/.NET/Microsoft.Recognizers.Text.DateTime/Extractors/BaseMergedDateTimeExtractor.cs @@ -121,12 +121,10 @@ public List Extract(string text, DateObject reference) ret = FilterUnspecificDatePeriod(ret); - ret = AddMod(ret, text); - // Remove common ambiguous cases ret = FilterAmbiguity(ret, text); - ret = FilterUnspecificTimePeriod(ret); + ret = AddMod(ret, text); // Filtering if ((this.config.Options & DateTimeOptions.CalendarMode) != 0) @@ -245,16 +243,6 @@ private List FilterUnspecificDatePeriod(List ers) return ers; } - private List FilterUnspecificTimePeriod(List ers) - { - if (this.config.UnspecificTimePeriodRegex != null) - { - ers.RemoveAll(o => this.config.UnspecificTimePeriodRegex.IsExactMatch(o.Text, true)); - } - - return ers; - } - private List FilterAmbiguity(List extractResults, string text) { if (this.config.AmbiguityFiltersDict != null) diff --git a/.NET/Microsoft.Recognizers.Text.DateTime/Extractors/BaseTimePeriodExtractor.cs b/.NET/Microsoft.Recognizers.Text.DateTime/Extractors/BaseTimePeriodExtractor.cs index 076fe92485..8ed6a18de8 100644 --- a/.NET/Microsoft.Recognizers.Text.DateTime/Extractors/BaseTimePeriodExtractor.cs +++ b/.NET/Microsoft.Recognizers.Text.DateTime/Extractors/BaseTimePeriodExtractor.cs @@ -310,7 +310,19 @@ private List MatchTimeOfDay(string text) var matches = this.config.TimeOfDayRegex.Matches(text); foreach (Match match in matches) { - ret.Add(new Token(match.Index, match.Index + match.Length)); + Metadata metadata = null; + + if (match.Groups[Constants.MealTimeGroupName].Success) + { + metadata = new Metadata + { + IsMealtime = true, + }; + } + + var token = new Token(match.Index, match.Index + match.Length, metadata); + + ret.Add(token); } return ret; diff --git a/.NET/Microsoft.Recognizers.Text/Extractors/Metadata.cs b/.NET/Microsoft.Recognizers.Text/Extractors/Metadata.cs index cfa84a6690..b02d8cd1c5 100644 --- a/.NET/Microsoft.Recognizers.Text/Extractors/Metadata.cs +++ b/.NET/Microsoft.Recognizers.Text/Extractors/Metadata.cs @@ -21,5 +21,7 @@ public class Metadata public string Offset { get; set; } = string.Empty; public string RelativeTo { get; set; } = string.Empty; + + public bool IsMealtime { get; set; } = false; } } diff --git a/Java/libraries/recognizers-text-date-time/src/main/java/com/microsoft/recognizers/text/datetime/resources/EnglishDateTime.java b/Java/libraries/recognizers-text-date-time/src/main/java/com/microsoft/recognizers/text/datetime/resources/EnglishDateTime.java index 8facd9eb41..5a781b17ad 100644 --- a/Java/libraries/recognizers-text-date-time/src/main/java/com/microsoft/recognizers/text/datetime/resources/EnglishDateTime.java +++ b/Java/libraries/recognizers-text-date-time/src/main/java/com/microsoft/recognizers/text/datetime/resources/EnglishDateTime.java @@ -1316,10 +1316,11 @@ public class EnglishDateTime { public static final List DurationDateRestrictions = Arrays.asList("today", "now"); public static final ImmutableMap AmbiguityFiltersDict = ImmutableMap.builder() - .put("\\bmorning|afternoon|evening|night|day\\b", "\\b(good\\s+(morning|afternoon|evening|night|day))|(nighty\\s+night)\\b") + .put("^(morning|afternoon|evening|night|day)\\b", "\\b(good\\s+(morning|afternoon|evening|night|day))|(nighty\\s+night)\\b") .put("\\bnow\\b", "\\b(^now,)|\\b((is|are)\\s+now\\s+for|for\\s+now)\\b") .put("\\bmay\\b", "\\b((((!|\\.|\\?|,|;|)\\s+|^)may i)|(i|you|he|she|we|they)\\s+may|(may\\s+((((also|not|(also not)|well)\\s+)?(be|ask|contain|constitute|e-?mail|take|have|result|involve|get|work|reply|differ))|(or may not))))\\b") .put("\\b(a|one) second\\b", "\\b(? MorningTermList = Arrays.asList("morning"); diff --git a/JavaScript/packages/recognizers-date-time/src/resources/englishDateTime.ts b/JavaScript/packages/recognizers-date-time/src/resources/englishDateTime.ts index 02fb418268..4f92552703 100644 --- a/JavaScript/packages/recognizers-date-time/src/resources/englishDateTime.ts +++ b/JavaScript/packages/recognizers-date-time/src/resources/englishDateTime.ts @@ -283,7 +283,7 @@ export namespace EnglishDateTime { export const DefaultLanguageFallback = 'MDY'; export const SuperfluousWordList = [ "preferably","how about","maybe","say","like" ]; export const DurationDateRestrictions = [ "today","now" ]; - export const AmbiguityFiltersDict: ReadonlyMap = new Map([["\\bmorning|afternoon|evening|night|day\\b", "\\b(good\\s+(morning|afternoon|evening|night|day))|(nighty\\s+night)\\b"],["\\bnow\\b", "\\b(^now,)|\\b((is|are)\\s+now\\s+for|for\\s+now)\\b"],["\\bmay\\b", "\\b((((!|\\.|\\?|,|;|)\\s+|^)may i)|(i|you|he|she|we|they)\\s+may|(may\\s+((((also|not|(also not)|well)\\s+)?(be|ask|contain|constitute|e-?mail|take|have|result|involve|get|work|reply|differ))|(or may not))))\\b"],["\\b(a|one) second\\b", "\\b(? = new Map([["^(morning|afternoon|evening|night|day)\\b", "\\b(good\\s+(morning|afternoon|evening|night|day))|(nighty\\s+night)\\b"],["\\bnow\\b", "\\b(^now,)|\\b((is|are)\\s+now\\s+for|for\\s+now)\\b"],["\\bmay\\b", "\\b((((!|\\.|\\?|,|;|)\\s+|^)may i)|(i|you|he|she|we|they)\\s+may|(may\\s+((((also|not|(also not)|well)\\s+)?(be|ask|contain|constitute|e-?mail|take|have|result|involve|get|work|reply|differ))|(or may not))))\\b"],["\\b(a|one) second\\b", "\\b(?