Recognizers-Text icon indicating copy to clipboard operation
Recognizers-Text copied to clipboard

[EN DateTimeV2] Issue recognizing dates in non-standard form (year missed)

Open SabreeswaranI opened this issue 3 years ago • 1 comments

Describe the bug We are using dot net version, The problem is that there is some problems with recognizing statements that start with year first '2014, Feb 17' or '2014 Feb 17', its able to pickup the month and day but its not picking up the year.

To Reproduce Use below phrases

  1. "2014, Feb 17 Lorem Ipsum is simply dummy text of the printing and typesetting industry."
  2. "2014 Feb 17 Lorem Ipsum is simply dummy text of the printing and typesetting industry."

Expected behavior It should pickup the year also and return "17-03-2014".

Sample input/output As applicable, add examples of text input and json output to help explain the problem.

Platform (please complete the following information):

  • Platform: .NET
  • Environment: nuget package
  • Version of package v1.8.6

Additional context Right now i resolve it using regex pattern replace like below: Regex.Replace(input, @"\b(?<year>\d{2,4})\s(?<month>[a-z]{3,9})\s(?<day>\d{1,2})\b", "${day}-${month}-${year}", RegexOptions.IgnoreCase, TimeSpan.FromMilliseconds(150));

SabreeswaranI avatar Mar 01 '23 11:03 SabreeswaranI

The current extraction rules explain the missing year. In English-DateTime.yaml, DateExtractor1 puts the year after month/day, while DateExtractorA requires punctuation between year, month, and day. English also sets CheckBothBeforeAfter to false, so ExtendWithWeekdayAndYear does not attach a preceding year. The parser's Match2Date already reads named year, month, and day groups.

A scoped addition for four-digit year + optional comma + named month + day would let the existing parser consume the year and preserve the original extraction offsets. Make this a named-month alternative, rather than broadly relaxing numeric separators. Update the YAML resource and regenerate the definitions.

Paired cases in DateExtractor.json and DateParser.json would protect the reported inputs. With a fixed 2026 reference, both 2014, Feb 17 Lorem Ipsum and 2014 Feb 17 Lorem Ipsum should extract the full 12-character date at start 0, with TIMEX, past resolution, and future resolution all 2014-02-17. Also include the single-space 2014 Feb 17 variant with length 11. February corresponds to month 02; the example's 17-03-2014 appears to be a typo. Existing specs cover 2019-sep-1 and 2019/sep/01, so retain those controls.

I maintain the MIT DateParser Kotlin; its explicit-year versus inherited-year fixtures offer the same regression invariant using day/month-first named dates. That is a Kotlin fixture reference, not a .NET dependency. I have not run Recognizers' tests.

Alox1d avatar Oct 15 '26 12:10 Alox1d