microsoft / Recognizers-Text

Microsoft.Recognizers.Text provides recognition and resolution of numbers, units, date/time, etc. in multiple languages (ZH, EN, FR, ES, PT, DE, IT, TR, HI, NL. Partial support for JA, KO, AR, SV). Packages available at: https://www.nuget.org/profiles/Recognizers.Text, https://www.npmjs.com/~recognizers.text
MIT License
1.66k stars 429 forks source link

Support for non-int time ranges in timex in c# #3106

Open sibbl opened 1 year ago

sibbl commented 1 year ago

Describe the bug From LUIS, I get a Timex valued PT0.5H. I'd like to parse the string with this library, but the parts (i.e. hours) must be an int. See code.

To Reproduce Steps to reproduce the behavior:

  1. Parse a Timex from the string PT0.5H via TimexResolver.Resolve(new[] { "PT0.5H });
  2. A ThrowOverflowOrFormatException is thrown.

Expected behavior The timex is parsed properly.

Platform (please complete the following information):

sibbl commented 1 year ago

Could decimal.Parse straight into the decimal Hours variable already solve it perhaps?