FormRognizer C#SDK不返回所有数据,将动态表视为文档字段

发布于 2025-01-30 07:12:33 字数 953 浏览 6 评论 0 原文

我创建了一个自定义模型,并且在“文档”下的JSON输出中可以很好地奏效,它为我标记的字段提供了所有数据点,以及我标记的动态类型表的所有数据点。

问题是C#SDK的“结果”,不像上面的JSON输出一样,使用相同的模型和示例包含表数据。

AnalyzeDocumentOperation operation = await client.StartAnalyzeDocumentAsync(modelID, streamContent);    
await operation.WaitForCompletionAsync();    
AnalyzeResult result = operation.Value;

可以在下面看到它可以抓住没有问题的字段

”“在此处输入图像说明”

但是,如果您查看下面的次数为空的,则与JSON数据不同,该数据在数组中具有所有数据点。

我如何访问数据?

谢谢。

I created a custom model and it works well in the Form Recognizer Studio, in the JSON output under the "Document" it gives all the data points for the Fields I tagged and also all the data points for the Dynamic type Table I tagged.

enter image description here

The issue is the "result" from the C# SDK does not contain the Table data like the JSON output above, using the same model and sample.

AnalyzeDocumentOperation operation = await client.StartAnalyzeDocumentAsync(modelID, streamContent);    
await operation.WaitForCompletionAsync();    
AnalyzeResult result = operation.Value;

Can see below it grabs the Fields without issue

enter image description here

but if you look at the TimeSheetDynamic below it is empty, unlike the JSON data which has all the data points in an array.

enter image description here

How do I access the data?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

我纯我任性 2025-02-06 07:12:33

您正在使用什么版本?需要使用的API版本为2.1及以上,以获取要识别的动态内容。

What version are you using? The API version needed to use is 2.1 and above to get the dynamic content to be recognized.

https://learn.microsoft.com/en-us/azure/applied-ai-services/form-recognizer/whats-new?tabs=csharp

江南月 2025-02-06 07:12:33

我遵循下面的GitHub样本访问非公共成员。感谢Vinod的样本。

 if (document.Fields.TryGetValue("Items", out DocumentField? itemsField))
            {
                if (itemsField.ValueType == DocumentFieldType.List)
                {
                    foreach (DocumentField itemField in itemsField.AsList())
                    {
                        Console.WriteLine("Item:");

                        if (itemField.ValueType == DocumentFieldType.Dictionary)
                        {
                            IReadOnlyDictionary<string, DocumentField> itemFields = itemField.AsDictionary();

                            if (itemFields.TryGetValue("Description", out DocumentField? itemDescriptionField))
                            {
                                if (itemDescriptionField.ValueType == DocumentFieldType.String)
                                {
                                    string itemDescription = itemDescriptionField.AsString();

                                    Console.WriteLine($"  Description: '{itemDescription}', with confidence {itemDescriptionField.Confidence}");
                                }
                            }

                            if (itemFields.TryGetValue("Amount", out DocumentField? itemAmountField))
                            {
                                if (itemAmountField.ValueType == DocumentFieldType.Double)
                                {
                                    double itemAmount = itemAmountField.AsDouble();

                                    Console.WriteLine($"  Amount: '{itemAmount}', with confidence {itemAmountField.Confidence}");
                                }
                            }
                        }
                    }
                }
            }

I followed the GitHub sample below to access the non-public members. Thanks Vinod for the sample.

 if (document.Fields.TryGetValue("Items", out DocumentField? itemsField))
            {
                if (itemsField.ValueType == DocumentFieldType.List)
                {
                    foreach (DocumentField itemField in itemsField.AsList())
                    {
                        Console.WriteLine("Item:");

                        if (itemField.ValueType == DocumentFieldType.Dictionary)
                        {
                            IReadOnlyDictionary<string, DocumentField> itemFields = itemField.AsDictionary();

                            if (itemFields.TryGetValue("Description", out DocumentField? itemDescriptionField))
                            {
                                if (itemDescriptionField.ValueType == DocumentFieldType.String)
                                {
                                    string itemDescription = itemDescriptionField.AsString();

                                    Console.WriteLine(
quot;  Description: '{itemDescription}', with confidence {itemDescriptionField.Confidence}");
                                }
                            }

                            if (itemFields.TryGetValue("Amount", out DocumentField? itemAmountField))
                            {
                                if (itemAmountField.ValueType == DocumentFieldType.Double)
                                {
                                    double itemAmount = itemAmountField.AsDouble();

                                    Console.WriteLine(
quot;  Amount: '{itemAmount}', with confidence {itemAmountField.Confidence}");
                                }
                            }
                        }
                    }
                }
            }

Sample Code GitHub Link

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文