Hi @Vijay Prime
Thank you for using Azure Document Intelligence. Based on screenshot (thanks for providing), you've trained a custom model, and the "Mechanical Properties" field is of type 'Fixed Table'.
In the JSON API response, you’ll find this table under (example for 'Tests''Hardness' cell):
analyzeResult.documents[0].fields["Mechanical Properties"].valueObject["Tests"].valueObject["Hardness"]
'Fixed Table' fields are represented as a "dictionary of dictionary".
Below is a C# sample (based on Custom_extraction_model.cs ) showing how to process 'Fixed Table' output:
//...
DocumentIntelligenceClient client = new DocumentIntelligenceClient(new Uri(endpoint), credential);
var analyzeOptions = new AnalyzeDocumentOptions(modelId, BinaryData.FromBytes(File.ReadAllBytes("c:\\temp\\SampleMechProp.png"))); // use your own local file
Operation<AnalyzeResult> operation = await client.AnalyzeDocumentAsync(WaitUntil.Completed, analyzeOptions);
AnalyzeResult result = operation.Value;
Console.WriteLine($"Document was analyzed with model with ID: {result.ModelId}");
foreach (AnalyzedDocument document in result.Documents)
{
foreach (var (fieldName, field) in document.Fields)
{
Console.WriteLine($"Field '{fieldName}': ");
// Illustration how to read output of Fixed Tables.
if (field.FieldType == DocumentFieldType.Dictionary)
{
var columnHeaders = field.ValueDictionary.SelectMany(rowField => rowField.Value.ValueDictionary.Keys).Distinct().ToList();
Console.WriteLine("{0,-15} {1}", "_RowKey_", string.Join(" ", columnHeaders.Select(h => $"{h,-15}")));
Console.WriteLine(new string('-', 15 + columnHeaders.Count * 15));
foreach (var (rowKey, rowValue) in field.ValueDictionary)
{
// Using value.Content for simplicity, but value.Value%Type% can be used to get normalized value of the subfield.
var rowValues = columnHeaders.Select(subFieldName => rowValue.ValueDictionary.TryGetValue(subFieldName, out var value) ? value.Content ?? "" : "").ToList();
Console.WriteLine("{0,-15} {1}", rowKey, string.Join(" ", rowValues.Select(v => $"{v,-15}")));
}
}
else
{
Console.WriteLine($"Content: '{field.Content}'");
}
}
}
I trained a sample model (similar to your) and ran this code. It prints:
Document was analyzed with model with ID: SampleFixedTableCustomer
Field 'Mechanical Properties':
_row_ Hardness Elongation %
---------------------------------------------
Min 137 22.00
Max 197
Actual 143,146,149 30.46
Please let me know if this doesn’t work for you.
Note: Install and reference the Azure.AI.DocumentIntelligence C# SDK v1.0.0 (not any 1.0.0-beta.x versions).
Best Regards,
=Anatoly=