How Training Custom Model for single word ?

Amol Harde 25 Reputation points
2023-07-01T04:15:58.27+00:00

Hi All,

Want to train a custom model for extracting single words have provided the screenshot below and highlighted the words that want to extract.

After trained want to use JAVA SDK for extraction.

Screenshot (102).jpg

Screenshot (103).jpg

Screenshot (104).jpg

Screenshot (105).jpg

Screenshot (106).jpg

Azure AI Document Intelligence
Azure AI Document Intelligence
An Azure service that turns documents into usable data. Previously known as Azure Form Recognizer.
1,707 questions
{count} votes

1 answer

Sort by: Most helpful
  1. romungi-MSFT 46,746 Reputation points Microsoft Employee
    2023-07-04T04:55:58.85+00:00

    @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.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.