Yes, you're on the right track using the DocumentField.Confidence property, but if you're working with tables (especially rows within a table), Azure Document Intelligence (formerly Form Recognizer) handles tables as a structured set of DocumentTable objects.
To get row-level confidence, you’ll need to access the DocumentTable, then go down to each cell, where you can get the Confidence per cell, and from that, aggregate to estimate the confidence for each row.
How to get row-level table confidence
Here’s how you can do it:
foreach (AnalyzedDocument document in result.Documents)
{
Console.WriteLine($"Document Type: {document.DocumentType}");
foreach (DocumentTable table in document.Tables)
{
Console.WriteLine("Processing a table...");
int rowIndex = 0;
foreach (var row in table.Cells.GroupBy(c => c.RowIndex))
{
double rowConfidence = row.Average(c => c.Confidence); // Averaging all cell confidences in the row
Console.WriteLine($"Row {rowIndex}: Confidence = {rowConfidence:P2}");
foreach (var cell in row)
{
Console.WriteLine($" Cell ({cell.RowIndex},{cell.ColumnIndex}): '{cell.Content}', Confidence: {cell.Confidence:P2}");
}
rowIndex++;
}
}
}
Explanation:
· document.Tables accesses all tables in a document.
· table.Cells gives all the cells, each of which has:
o RowIndex and ColumnIndex
o Content
o Confidence
· Cells are grouped by RowIndex to simulate rows.
· Confidence for a row is computed as the average confidence of its cells (you can also take min/max/median based on your quality strategy).
Notes:
· This method does not give a single "row confidence" field natively, but it's the best approximation.
· If you’re using Azure.AI.FormRecognizer.DocumentAnalysis, make sure you’re using v3.2+ SDK to access all these properties.
Hope this helps. Do let me know if you any further queries.
If this answers your query, do click Accept Answer
and Yes
for was this answer helpful. And, if you have any further query do let us know.
Thank you!