[Infra] Best practice sharing asked for decimal parsing when separator doesn't match culture #2346
-
I'm looking for best practices regarding decimal number parsing, when the sources decimal separator does not match its culture. Example:
in the above document, according to the culture the decimal separator should be Source code used: var culture = new CultureInfo(language);
var recognizer = new NumberWithUnitRecognizer(language);
var model = recognizer.GetDimensionModel();
var results = model.Parse(ingredient); Example document: https://www.ah.nl/allerhande/recept/R-R1194447/rendang
Wanted result: Could you give some suggestions? What would be a good approach to handle this in a smart way? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Unfortunately currently the recognizers depend strongly on the culture for such determinations as the decimal separator and how to parse numbers. |
Beta Was this translation helpful? Give feedback.
Unfortunately currently the recognizers depend strongly on the culture for such determinations as the decimal separator and how to parse numbers.
But in this case, "2" should not be parsed as a number. This is a bug that should be fixed. According to the current design, the "correct" output here would be only "kg" as a Dimension entity with no numerical value.
The project backlog also includes the capability to allow users to customize resolution policy (for example, specify a less strict processing of the decimal separator), but there's no ETA for this to be exposed yet.