@Amol Harde Sure, this sample should help you get the required key field and print its confidence and bounding regions.
String documentUrl = "{document-url}";
String modelId = "{custom-built-model-ID}";
SyncPoller<OperationResult, AnalyzeResult> analyzeDocumentPoller =
documentAnalysisClient.beginAnalyzeDocumentFromUrl(modelId, documentUrl);
AnalyzeResult analyzeResult = analyzeDocumentPoller.getFinalResult();
for (int i = 0; i < analyzeResult.getDocuments().size(); i++) {
final AnalyzedDocument analyzedDocument = analyzeResult.getDocuments().get(i);
System.out.printf("----------- Analyzing custom document %d -----------%n", i);
System.out.printf("Analyzed document has doc type %s with confidence : %.2f%n",
analyzedDocument.getDocType(), analyzedDocument.getConfidence());
analyzedDocument.getFields().forEach((key, documentField) -> {
System.out.printf("Document Field content: %s%n", documentField.getContent());
System.out.printf("Document Field confidence: %.2f%n", documentField.getConfidence());
System.out.printf("Document Field Type: %s%n", documentField.getType());
System.out.printf("Document Field found within bounding region: %s%n",
documentField.getBoundingRegions().toString());
});
}
The above snippet reads the fields and prints its confidence and bounding region. For the example model I used above the response in raw JSON would be like below, which is being read by SDK snippet above.
"fields": {
"Recomendation": {
"type": "string",
"valueString": "BUY",
"content": "BUY",
"boundingRegions": [
{
"pageNumber": 1,
"polygon": [
423,
61,
445,
61,
445,
72,
423,
72
]
}
],
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.