Closed yowl closed 2 years ago
Thank you for your feedback. Tagging and routing to the team member best able to assist.
@kinelski @maririos is this something we should add?
AsDouble/AsDecimal methods won't do you any good if the data is stored internally as a float (the precision is already lost). I just want to make sure it is taken into account that the underlying datatype needs to change to solve this issue.
@Rodrick45 is this directed at me (author)? I'm working around this by using a string, so assume internally the data is there in its complete form as read from the OCR. E.g.
var field = Form.Fields["allowedLaytime"];
decimal d;
if (decimal.TryParse(field.ValueData.Text, NumberStyles.AllowDecimalPoint | NumberStyles.AllowThousands, ci, out d))
{
I was directing my comment at whoever will be fixing this issue in the toolkit. Your workaround seems fine and is similar to what we had to do. Sorry for the confusion.
@Rodrick45 the service manages the numbers as double
. The SDK is casting it as a float
and then exposing it, so in the SDK we should definitely consider exposing AsDouble
so there is no precision lost.
@kinelski @maririos is this something we should add?
@AlexGhiondea yes. We want to add it for future releases (4.0.0-beta.1). For other versions, we could consider leave as is as there is a workaround (like @yowl mentioned) or do a 3.2.0 GA
release to include this.
Update: the new DocumentField
class introduced in SDK version 4.0.0-beta.1 contains an AsDouble
method, as suggested. Here's a complete migration guide if there's any help needed in migrating to the new version: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/formrecognizer/Azure.AI.FormRecognizer/MigrationGuide.md
Closing this issue since it's been solved long ago. Feel free to open a new one if there are any other concerns.
Query/Question Looking at https://docs.microsoft.com/en-us/dotnet/api/azure.ai.formrecognizer.models.fieldvalue.ascountrycode?view=azure-dotnet-preview&viewFallbackFrom=azure-dotnet
If you have high precision numbers, and many forms require more than
Single
provides, why are there no methods for AsDouble or AsDecimal? I suppose the workaround is to leave as string type and do the conversion in userland.Environment: -Azure.AI.FormRecognizer v3.1.0-beta.4