question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[QUERY] AsFloat() Should there be an option for locale?

See original GitHub issue

Query/Question For Europe and Latin America, numbers use commas for decimal points so for the input 180,00 (that’s a comma). In US/UK terms that would be 180.00 (one hundred and eighty), but there doesn’t appear to be a way to get ToFloat to accept that.

In the RecognizedForm json it is:

          {
            "type": "number",
            "text": "180,00",
            "page": 1,
            "boundingBox": [3.23, 9.19, 3.56, 9.19, 3.56, 9.285, 3.23, 9.285],
            "confidence": 0.995,
            "elements": ["#/readResults/0/lines/96/words/4"]
          },

And if you do AsFloat() on that you get 18000. How can you tell AsFloat what the locale is?

As a workaround I am doing:

            if (decimal.TryParse(field.ValueData.Text, NumberStyles.AllowDecimalPoint | NumberStyles.AllowThousands, new CultureInfo("de-DE"), out d))
            {

Environment:

  • Azure.AI.FormRecognizer 3.1.0-beta.4

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
maririoscommented, Apr 14, 2021

After following up, currently StartRecognizeCustomForms doesn’t support locale on the service side. Other functions, like for example, StartRecognizeBusinessCards or StartRecognizeInvoices do.

The service is working on adding it though but there isn’t a specific date yet for it. For now, your workaround is the best option.

1reaction
maririoscommented, Apr 12, 2021

Note in this case service is not returning valueNumber, and the code is following a workaround done for receipt https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/formrecognizer/Azure.AI.FormRecognizer/src/FieldValue.cs#L244 FYI @kinelski

This belongs to the deeper conversation of what to do when service doesn’t return value<type>. Should text be used?

Related to #17712

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to format a float with a comma as decimal separator in ...
If you want to format floats with a comma within the f-string, you can either use replace after casting the float to a...
Read more >
SQL Convert Function
In this example, we will convert a float data type to integer. In the following query, we will declare a variable that data...
Read more >
Solved: Having issues with Converting String to float or i...
I have a problem as I am reeding excel cell it says for ex 10.57 power automate gives me 1,057 as float how...
Read more >
What's New In Python 3.11 — Python 3.11.4 documentation
This article explains the new features in Python 3.11, compared to 3.10. ... For example, a SQL query function could be annotated as...
Read more >
class-wpdb - WordPress Developer Resources
Since this method uses the $wpdb->query() method, all the class variables are properly set. The results count for a 'SELECT' query will be...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found