FormRecognizerClient クラス

  • java.lang.Object
    • com.azure.ai.formrecognizer.FormRecognizerClient

public final class FormRecognizerClient

このクラスは、Form Recognizer Azure Cognitive Service に接続するための同期クライアントを提供します。

このクライアントは、以下を実行する同期メソッドを提供します。

  1. カスタム フォーム分析: 個別のビジネス データとユース ケースに固有のフォームやドキュメントからのデータの抽出と分析。 modelId を メソッドに渡して、カスタムトレーニング済みモデルを beginRecognizeCustomForms 使用します。
  2. 事前構築済みモデル分析: サポートされている事前構築済みモデル を使用して、領収書、名刺、請求書、その他のドキュメントを分析する 方法を beginRecognizeReceipts 使用して、領収書情報を認識します。
  3. レイアウト分析: フォームとドキュメントからのテキスト、選択マーク、テーブル、境界ボックス座標の抽出と分析。 tpo メソッドを使用して beginRecognizeContent(InputStream form, long length) レイアウト分析を実行します。
  4. ポーリングとコールバック: サービスをポーリングして分析操作の状態をチェックしたり、分析が完了したときに通知を受信するためのコールバックを登録したりするメカニズムが含まれています。

API バージョン 2022-08-31 以降を使用するには、 移行ガイド を参照してください。

サービス クライアントは、開発者が Azure Form Recognizerを使用するための対話のポイントです。 FormRecognizerClient は同期サービス クライアントであり、 FormRecognizerAsyncClient 非同期サービス クライアントです。 このドキュメントに示す例では、認証に DefaultAzureCredential という名前の資格情報オブジェクトを使用します。これは、ローカルの開発環境や運用環境など、ほとんどのシナリオに適しています。 さらに、運用環境での認証には マネージド ID を 使用することをお勧めします。 さまざまな認証方法と、それに対応する資格情報の種類の詳細については、 Azure Identity のドキュメントを参照してください

サンプル: DefaultAzureCredential を使用して FormRecognizerClient を構築する

次のコード サンプルは、'DefaultAzureCredentialBuilder' を使用して を構成する の作成 FormRecognizerClientを示しています。

FormRecognizerClient formRecognizerClient = new FormRecognizerClientBuilder()
     .endpoint("{endpoint}")
     .credential(new DefaultAzureCredentialBuilder().build())
     .buildClient();

さらに、クライアントの作成に使用 AzureKeyCredential する次のコード サンプルを参照してください。

FormRecognizerClient formRecognizerClient = new FormRecognizerClientBuilder()
     .credential(new AzureKeyCredential("{key}"))
     .endpoint("{endpoint}")
     .buildClient();

メソッドの概要

修飾子と型 メソッドと説明
SyncPoller<FormRecognizerOperationResult,List<RecognizedForm>> beginRecognizeBusinessCards(InputStream businessCard, long length)

光学式文字認識 (OCR) と事前構築済みのトレーニング済みのビジネス カード モデルを使用して、提供されたドキュメント データからビジネス カード データを認識します。

SyncPoller<FormRecognizerOperationResult,List<RecognizedForm>> beginRecognizeBusinessCards(InputStream businessCard, long length, RecognizeBusinessCardsOptions recognizeBusinessCardsOptions, Context context)

光学式文字認識 (OCR) と事前構築済みのトレーニング済みのビジネス カード モデルを使用して、提供されたドキュメント データからビジネス カード データを認識します。

SyncPoller<FormRecognizerOperationResult,List<RecognizedForm>> beginRecognizeBusinessCardsFromUrl(String businessCardUrl)

光学式文字認識 (OCR) と事前構築済みのビジネス カードトレーニング済みモデルを使用して、ドキュメントからビジネス カード データを認識します。

SyncPoller<FormRecognizerOperationResult,List<RecognizedForm>> beginRecognizeBusinessCardsFromUrl(String businessCardUrl, RecognizeBusinessCardsOptions recognizeBusinessCardsOptions, Context context)

光学式文字認識 (OCR) と事前構築済みのビジネス カードトレーニング済みモデルを使用して、ドキュメントからビジネス カード データを認識します。

SyncPoller<FormRecognizerOperationResult,List<FormPage>> beginRecognizeContent(InputStream form, long length)

光学式文字認識 (OCR) とカスタムトレーニング済みモデルを使用して、レイアウト データを認識します。

SyncPoller<FormRecognizerOperationResult,List<FormPage>> beginRecognizeContent(InputStream form, long length, RecognizeContentOptions recognizeContentOptions, Context context)

光学式文字認識 (OCR) を使用して、指定されたドキュメント データのコンテンツ/レイアウト データを認識します。

SyncPoller<FormRecognizerOperationResult,List<FormPage>> beginRecognizeContentFromUrl(String formUrl)

光学式文字認識 (OCR) を使用して、ドキュメントのコンテンツ/レイアウト データを認識します。

SyncPoller<FormRecognizerOperationResult,List<FormPage>> beginRecognizeContentFromUrl(String formUrl, RecognizeContentOptions recognizeContentOptions, Context context)

光学式文字認識 (OCR) を使用してコンテンツ/レイアウト データを認識します。

SyncPoller<FormRecognizerOperationResult,List<RecognizedForm>> beginRecognizeCustomForms(String modelId, InputStream form, long length)

光学式文字認識 (OCR) と、ラベル付きまたはラベルなしのカスタムトレーニング済みモデルを使用して、ドキュメントからフォーム データを認識します。

SyncPoller<FormRecognizerOperationResult,List<RecognizedForm>> beginRecognizeCustomForms(String modelId, InputStream form, long length, RecognizeCustomFormsOptions recognizeCustomFormsOptions, Context context)

光学式文字認識 (OCR) とカスタムトレーニング済みモデルを使用して、ドキュメントからフォーム データを認識します。

SyncPoller<FormRecognizerOperationResult,List<RecognizedForm>> beginRecognizeCustomFormsFromUrl(String modelId, String formUrl)

光学式文字認識 (OCR) と、ラベル付きまたはラベルなしのカスタムトレーニング済みモデルを使用して、ドキュメントからフォーム データを認識します。

SyncPoller<FormRecognizerOperationResult,List<RecognizedForm>> beginRecognizeCustomFormsFromUrl(String modelId, String formUrl, RecognizeCustomFormsOptions recognizeCustomFormsOptions, Context context)

光学式文字認識 (OCR) とカスタムトレーニング済みモデルを使用して、ドキュメントからフォーム データを認識します。

SyncPoller<FormRecognizerOperationResult,List<RecognizedForm>> beginRecognizeIdentityDocuments(InputStream identityDocument, long length)

光学式文字認識 (OCR) と ID ドキュメント モデルでトレーニングされた事前構築済みモデルを使用して ID ドキュメントを分析し、パスポートと米国の運転免許証から重要な情報を抽出します。

SyncPoller<FormRecognizerOperationResult,List<RecognizedForm>> beginRecognizeIdentityDocuments(InputStream identityDocument, long length, RecognizeIdentityDocumentOptions recognizeIdentityDocumentOptions, Context context)

光学式文字認識 (OCR) と ID ドキュメント モデルでトレーニングされた事前構築済みモデルを使用して ID ドキュメントを分析し、パスポートと米国の運転免許証から重要な情報を抽出します。

SyncPoller<FormRecognizerOperationResult,List<RecognizedForm>> beginRecognizeIdentityDocumentsFromUrl(String identityDocumentUrl)

光学式文字認識 (OCR) と ID ドキュメント モデルでトレーニングされた事前構築済みモデルを使用して ID ドキュメントを分析し、パスポートと米国の運転免許証から重要な情報を抽出します。

SyncPoller<FormRecognizerOperationResult,List<RecognizedForm>> beginRecognizeIdentityDocumentsFromUrl(String identityDocumentUrl, RecognizeIdentityDocumentOptions recognizeIdentityDocumentOptions, Context context)

光学式文字認識 (OCR) と ID ドキュメント モデルでトレーニングされた事前構築済みモデルを使用して ID ドキュメントを分析し、パスポートと米国の運転免許証から重要な情報を抽出します。

SyncPoller<FormRecognizerOperationResult,List<RecognizedForm>> beginRecognizeInvoices(InputStream invoice, long length)

光学式文字認識 (OCR) と事前構築済みのトレーニング済み請求書モデルを使用して、指定されたドキュメント データのデータを認識します。

SyncPoller<FormRecognizerOperationResult,List<RecognizedForm>> beginRecognizeInvoices(InputStream invoice, long length, RecognizeInvoicesOptions recognizeInvoicesOptions, Context context)

光学式文字認識 (OCR) と事前構築済みのトレーニング済み請求書モデルを使用して、指定されたドキュメント データのデータを認識します。

SyncPoller<FormRecognizerOperationResult,List<RecognizedForm>> beginRecognizeInvoicesFromUrl(String invoiceUrl)

光学式文字認識 (OCR) と事前構築済みの請求書トレーニング済みモデルを使用して、ドキュメントからの請求書データを認識します。

SyncPoller<FormRecognizerOperationResult,List<RecognizedForm>> beginRecognizeInvoicesFromUrl(String invoiceUrl, RecognizeInvoicesOptions recognizeInvoicesOptions, Context context)

光学式文字認識 (OCR) と事前構築済みの請求書トレーニング済みモデルを使用して、ドキュメントからの請求書データを認識します。

SyncPoller<FormRecognizerOperationResult,List<RecognizedForm>> beginRecognizeReceipts(InputStream receipt, long length)

光学式文字認識 (OCR) と事前構築済みのトレーニング済みレシート モデルを使用して、指定されたドキュメント データのデータを認識します。

SyncPoller<FormRecognizerOperationResult,List<RecognizedForm>> beginRecognizeReceipts(InputStream receipt, long length, RecognizeReceiptsOptions recognizeReceiptsOptions, Context context)

光学式文字認識 (OCR) と事前構築済みのトレーニング済みレシート モデルを使用して、指定されたドキュメント データのデータを認識します。

SyncPoller<FormRecognizerOperationResult,List<RecognizedForm>> beginRecognizeReceiptsFromUrl(String receiptUrl)

光学式文字認識 (OCR) と事前構築済みのレシートトレーニング済みモデルを使用して、ドキュメントからのレシート データを認識します。

SyncPoller<FormRecognizerOperationResult,List<RecognizedForm>> beginRecognizeReceiptsFromUrl(String receiptUrl, RecognizeReceiptsOptions recognizeReceiptsOptions, Context context)

光学式文字認識 (OCR) と事前構築済みのレシートトレーニング済みモデルを使用して、ドキュメントからのレシート データを認識します。

メソッドの継承元: java.lang.Object

メソッドの詳細

beginRecognizeBusinessCards

public SyncPoller<>> beginRecognizeBusinessCards(InputStream businessCard, long length)

光学式文字認識 (OCR) と事前構築済みのトレーニング済みのビジネス カード モデルを使用して、提供されたドキュメント データからビジネス カード データを認識します。

サービスは実行時間の長い操作の取り消しをサポートせず、取り消しサポートがないことを示すエラー メッセージを返します

ビジネス カードのフィールドについては、こちらを参照してください。

Code sample

File businessCard = new File("{local/file_path/fileName.jpg}");
 byte[] fileContent = Files.readAllBytes(businessCard.toPath());
 try (InputStream targetStream = new ByteArrayInputStream(fileContent)) {
     formRecognizerClient.beginRecognizeBusinessCards(targetStream, businessCard.length()).getFinalResult()
         .forEach(recognizedBusinessCard -> {
             Map<String, FormField> recognizedFields = recognizedBusinessCard.getFields();
             FormField contactNamesFormField = recognizedFields.get("ContactNames");
             if (contactNamesFormField != null) {
                 if (FieldValueType.LIST == contactNamesFormField.getValue().getValueType()) {
                     List<FormField> contactNamesList = contactNamesFormField.getValue().asList();
                     contactNamesList.stream()
                         .filter(contactName -> FieldValueType.MAP == contactName.getValue().getValueType())
                         .map(contactName -> {
                             System.out.printf("Contact name: %s%n", contactName.getValueData().getText());
                             return contactName.getValue().asMap();
                         })
                         .forEach(contactNamesMap -> contactNamesMap.forEach((key, contactName) -> {
                             if ("FirstName".equals(key)) {
                                 if (FieldValueType.STRING == contactName.getValue().getValueType()) {
                                     String firstName = contactName.getValue().asString();
                                     System.out.printf("\tFirst Name: %s, confidence: %.2f%n",
                                         firstName, contactName.getConfidence());
                                 }
                             }
                             if ("LastName".equals(key)) {
                                 if (FieldValueType.STRING == contactName.getValue().getValueType()) {
                                     String lastName = contactName.getValue().asString();
                                     System.out.printf("\tLast Name: %s, confidence: %.2f%n",
                                         lastName, contactName.getConfidence());
                                 }
                             }
                         }));
                 }
             }
             FormField jobTitles = recognizedFields.get("JobTitles");
             if (jobTitles != null) {
                 if (FieldValueType.LIST == jobTitles.getValue().getValueType()) {
                     List<FormField> jobTitlesItems = jobTitles.getValue().asList();
                     jobTitlesItems.forEach(jobTitlesItem -> {
                         if (FieldValueType.STRING == jobTitlesItem.getValue().getValueType()) {
                             String jobTitle = jobTitlesItem.getValue().asString();
                             System.out.printf("Job Title: %s, confidence: %.2f%n",
                                 jobTitle, jobTitlesItem.getConfidence());
                         }
                     });
                 }
             }
         });
 }

Parameters:

businessCard - ビジネスカード情報を認識するビジネス カードのデータ。
length - データの正確な長さ。

Returns:

SyncPoller<T,U>完了、失敗、または取り消されるまで、ビジネス カード認識操作をポーリングする 。 完了した操作は、 の RecognizedForm一覧を返します。

beginRecognizeBusinessCards

public SyncPoller<>> beginRecognizeBusinessCards(InputStream businessCard, long length, RecognizeBusinessCardsOptions recognizeBusinessCardsOptions, Context context)

光学式文字認識 (OCR) と事前構築済みのトレーニング済みのビジネス カード モデルを使用して、提供されたドキュメント データからビジネス カード データを認識します。

サービスは実行時間の長い操作の取り消しをサポートせず、取り消しサポートがないことを示すエラー メッセージを返します

ビジネス カードのフィールドについては、こちらを参照してください。

Code sample

File businessCard = new File("{local/file_path/fileName.jpg}");
 boolean includeFieldElements = true;
 byte[] fileContent = Files.readAllBytes(businessCard.toPath());
 try (InputStream targetStream = new ByteArrayInputStream(fileContent)) {
     for (RecognizedForm recognizedForm : formRecognizerClient.beginRecognizeBusinessCards(targetStream,
         businessCard.length(),
         new RecognizeBusinessCardsOptions()
             .setContentType(FormContentType.IMAGE_JPEG)
             .setFieldElementsIncluded(includeFieldElements),
         Context.NONE).setPollInterval(Duration.ofSeconds(5))
         .getFinalResult()) {
         Map<String, FormField> recognizedFields = recognizedForm.getFields();
         FormField contactNamesFormField = recognizedFields.get("ContactNames");
         if (contactNamesFormField != null) {
             if (FieldValueType.LIST == contactNamesFormField.getValue().getValueType()) {
                 List<FormField> contactNamesList = contactNamesFormField.getValue().asList();
                 contactNamesList.stream()
                     .filter(contactName -> FieldValueType.MAP == contactName.getValue().getValueType())
                     .map(contactName -> {
                         System.out.printf("Contact name: %s%n", contactName.getValueData().getText());
                         return contactName.getValue().asMap();
                     })
                     .forEach(contactNamesMap -> contactNamesMap.forEach((key, contactName) -> {
                         if ("FirstName".equals(key)) {
                             if (FieldValueType.STRING == contactName.getValue().getValueType()) {
                                 String firstName = contactName.getValue().asString();
                                 System.out.printf("\tFirst Name: %s, confidence: %.2f%n",
                                     firstName, contactName.getConfidence());
                             }
                         }
                         if ("LastName".equals(key)) {
                             if (FieldValueType.STRING == contactName.getValue().getValueType()) {
                                 String lastName = contactName.getValue().asString();
                                 System.out.printf("\tLast Name: %s, confidence: %.2f%n",
                                     lastName, contactName.getConfidence());
                             }
                         }
                     }));
             }
         }
         FormField jobTitles = recognizedFields.get("JobTitles");
         if (jobTitles != null) {
             if (FieldValueType.LIST == jobTitles.getValue().getValueType()) {
                 List<FormField> jobTitlesItems = jobTitles.getValue().asList();
                 jobTitlesItems.forEach(jobTitlesItem -> {
                     if (FieldValueType.STRING == jobTitlesItem.getValue().getValueType()) {
                         String jobTitle = jobTitlesItem.getValue().asString();
                         System.out.printf("Job Title: %s, confidence: %.2f%n",
                             jobTitle, jobTitlesItem.getConfidence());
                     }
                 });
             }
         }
     }
 }

Parameters:

businessCard - ビジネスカード情報を認識するビジネス カードのデータ。
length - データの正確な長さ。
recognizeBusinessCardsOptions - ビジネス カードを分析するときに渡される可能性がある追加の構成可能RecognizeBusinessCardsOptions
context - サービス呼び出し中に HTTP パイプラインを介して渡される追加のコンテキスト。

Returns:

SyncPoller<T,U>完了、失敗、または取り消されるまで、ビジネス カード認識操作をポーリングする 。 完了した操作は、 の RecognizedForm一覧を返します。

beginRecognizeBusinessCardsFromUrl

public SyncPoller<>> beginRecognizeBusinessCardsFromUrl(String businessCardUrl)

光学式文字認識 (OCR) と事前構築済みのビジネス カードトレーニング済みモデルを使用して、ドキュメントからビジネス カード データを認識します。

サービスは実行時間の長い操作の取り消しをサポートせず、取り消しサポートがないことを示すエラー メッセージを返します

ビジネス カードのフィールドについては、こちらを参照してください。

Code sample

String businessCardUrl = "{business_card_url}";
 formRecognizerClient.beginRecognizeBusinessCardsFromUrl(businessCardUrl)
     .getFinalResult()
     .forEach(recognizedBusinessCard -> {
         Map<String, FormField> recognizedFields = recognizedBusinessCard.getFields();
         FormField contactNamesFormField = recognizedFields.get("ContactNames");
         if (contactNamesFormField != null) {
             if (FieldValueType.LIST == contactNamesFormField.getValue().getValueType()) {
                 List<FormField> contactNamesList = contactNamesFormField.getValue().asList();
                 contactNamesList.stream()
                     .filter(contactName -> FieldValueType.MAP == contactName.getValue().getValueType())
                     .map(contactName -> {
                         System.out.printf("Contact name: %s%n", contactName.getValueData().getText());
                         return contactName.getValue().asMap();
                     })
                     .forEach(contactNamesMap -> contactNamesMap.forEach((key, contactName) -> {
                         if ("FirstName".equals(key)) {
                             if (FieldValueType.STRING == contactName.getValue().getValueType()) {
                                 String firstName = contactName.getValue().asString();
                                 System.out.printf("\tFirst Name: %s, confidence: %.2f%n",
                                     firstName, contactName.getConfidence());
                             }
                         }
                         if ("LastName".equals(key)) {
                             if (FieldValueType.STRING == contactName.getValue().getValueType()) {
                                 String lastName = contactName.getValue().asString();
                                 System.out.printf("\tLast Name: %s, confidence: %.2f%n",
                                     lastName, contactName.getConfidence());
                             }
                         }
                     }));
             }
         }
         FormField jobTitles = recognizedFields.get("JobTitles");
         if (jobTitles != null) {
             if (FieldValueType.LIST == jobTitles.getValue().getValueType()) {
                 List<FormField> jobTitlesItems = jobTitles.getValue().asList();
                 jobTitlesItems.forEach(jobTitlesItem -> {
                     if (FieldValueType.STRING == jobTitlesItem.getValue().getValueType()) {
                         String jobTitle = jobTitlesItem.getValue().asString();
                         System.out.printf("Job Title: %s, confidence: %.2f%n",
                             jobTitle, jobTitlesItem.getConfidence());
                     }
                 });
             }
         }
     });

Parameters:

businessCardUrl - 入力ビジネス カードのソース URL。

Returns:

完了SyncPoller<T,U>、失敗、または取り消されるまで、ビジネス カード認識操作の進行状況をポーリングする 。 完了した操作は、 の RecognizedForm一覧を返します。

beginRecognizeBusinessCardsFromUrl

public SyncPoller<>> beginRecognizeBusinessCardsFromUrl(String businessCardUrl, RecognizeBusinessCardsOptions recognizeBusinessCardsOptions, Context context)

光学式文字認識 (OCR) と事前構築済みのビジネス カードトレーニング済みモデルを使用して、ドキュメントからビジネス カード データを認識します。

サービスは実行時間の長い操作の取り消しをサポートせず、取り消しサポートがないことを示すエラー メッセージを返します

ビジネス カードのフィールドについては、こちらを参照してください。

Code sample

String businessCardUrl = "{business_card_url}";
 formRecognizerClient.beginRecognizeBusinessCardsFromUrl(businessCardUrl,
     new RecognizeBusinessCardsOptions()
         .setFieldElementsIncluded(true), Context.NONE)
     .setPollInterval(Duration.ofSeconds(5)).getFinalResult()
     .forEach(recognizedBusinessCard -> {
         Map<String, FormField> recognizedFields = recognizedBusinessCard.getFields();
         FormField contactNamesFormField = recognizedFields.get("ContactNames");
         if (contactNamesFormField != null) {
             if (FieldValueType.LIST == contactNamesFormField.getValue().getValueType()) {
                 List<FormField> contactNamesList = contactNamesFormField.getValue().asList();
                 contactNamesList.stream()
                     .filter(contactName -> FieldValueType.MAP == contactName.getValue().getValueType())
                     .map(contactName -> {
                         System.out.printf("Contact name: %s%n", contactName.getValueData().getText());
                         return contactName.getValue().asMap();
                     })
                     .forEach(contactNamesMap -> contactNamesMap.forEach((key, contactName) -> {
                         if ("FirstName".equals(key)) {
                             if (FieldValueType.STRING == contactName.getValue().getValueType()) {
                                 String firstName = contactName.getValue().asString();
                                 System.out.printf("\tFirst Name: %s, confidence: %.2f%n",
                                     firstName, contactName.getConfidence());
                             }
                         }
                         if ("LastName".equals(key)) {
                             if (FieldValueType.STRING == contactName.getValue().getValueType()) {
                                 String lastName = contactName.getValue().asString();
                                 System.out.printf("\tLast Name: %s, confidence: %.2f%n",
                                     lastName, contactName.getConfidence());
                             }
                         }
                     }));
             }
         }
         FormField jobTitles = recognizedFields.get("JobTitles");
         if (jobTitles != null) {
             if (FieldValueType.LIST == jobTitles.getValue().getValueType()) {
                 List<FormField> jobTitlesItems = jobTitles.getValue().asList();
                 jobTitlesItems.forEach(jobTitlesItem -> {
                     if (FieldValueType.STRING == jobTitlesItem.getValue().getValueType()) {
                         String jobTitle = jobTitlesItem.getValue().asString();
                         System.out.printf("Job Title: %s, confidence: %.2f%n",
                             jobTitle, jobTitlesItem.getConfidence());
                     }
                 });
             }
         }
     });

Parameters:

businessCardUrl - 入力ビジネス カードのソース URL。
recognizeBusinessCardsOptions - ビジネス カードを分析するときに渡される可能性がある追加の構成可能RecognizeBusinessCardsOptions
context - サービス呼び出し中に HTTP パイプラインを介して渡される追加のコンテキスト。

Returns:

SyncPoller<T,U>完了、失敗、または取り消されるまで、ビジネス カード認識操作の進行状況をポーリングする 。 完了した操作は、 の一覧 RecognizedFormを返します。

beginRecognizeContent

public SyncPoller<>> beginRecognizeContent(InputStream form, long length)

光学式文字認識 (OCR) とカスタムトレーニング済みモデルを使用して、レイアウト データを認識します。

このサービスは、実行時間の長い操作の取り消しをサポートせず、取り消しサポートがないことを示すエラー メッセージを返します。

Code sample

File form = new File("{local/file_path/fileName.pdf}");
 byte[] fileContent = Files.readAllBytes(form.toPath());
 try (InputStream targetStream = new ByteArrayInputStream(fileContent)) {
     formRecognizerClient.beginRecognizeContent(targetStream, form.length())
         .getFinalResult()
         .forEach(formPage -> {
             System.out.printf("Page Angle: %s%n", formPage.getTextAngle());
             System.out.printf("Page Dimension unit: %s%n", formPage.getUnit());
             // Table information
             System.out.println("Recognized Tables: ");
             formPage.getTables()
                 .stream()
                 .flatMap(formTable -> formTable.getCells().stream())
                 .forEach(recognizedTableCell -> System.out.printf("%s ", recognizedTableCell.getText()));
         });
 }

Parameters:

form - コンテンツ情報を認識するフォームのデータ。
length - データの正確な長さ。

Returns:

SyncPoller<T,U>完了、失敗、または取り消されるまで、コンテンツ認識操作をポーリングする 。 完了した操作は、 の一覧 FormPageを返します。

beginRecognizeContent

public SyncPoller<>> beginRecognizeContent(InputStream form, long length, RecognizeContentOptions recognizeContentOptions, Context context)

光学式文字認識 (OCR) を使用して、指定されたドキュメント データのコンテンツ/レイアウト データを認識します。

サービスは実行時間の長い操作の取り消しをサポートせず、取り消しサポートがないことを示すエラー メッセージを返します

コンテンツ認識では、自動言語識別と多言語ドキュメントがサポートされているため、 でドキュメントを特定の言語として処理するように強制する場合にのみ言語コードを RecognizeContentOptions提供します。

Code sample

File form = new File("{file_source_url}");
 byte[] fileContent = Files.readAllBytes(form.toPath());
 try (InputStream targetStream = new ByteArrayInputStream(fileContent)) {

     for (FormPage formPage : formRecognizerClient.beginRecognizeContent(targetStream, form.length(),
         new RecognizeContentOptions()
             .setPollInterval(Duration.ofSeconds(5)), Context.NONE)
         .getFinalResult()) {
         System.out.printf("Page Angle: %s%n", formPage.getTextAngle());
         System.out.printf("Page Dimension unit: %s%n", formPage.getUnit());
         // Table information
         System.out.println("Recognized Tables: ");
         formPage.getTables()
             .stream()
             .flatMap(formTable -> formTable.getCells().stream())
             .forEach(recognizedTableCell -> System.out.printf("%s ", recognizedTableCell.getText()));
     }
 }

Parameters:

form - コンテンツ情報を認識するフォームのデータ。
length - データの正確な長さ。
recognizeContentOptions - フォーム上のコンテンツ/レイアウトを認識するときに渡される可能性がある追加の構成可能 RecognizeContentOptions
context - サービス呼び出し中に HTTP パイプラインを介して渡される追加のコンテキスト。

Returns:

SyncPoller<T,U>完了、失敗、または取り消されるまで、コンテンツ認識操作をポーリングする 。 完了した操作は、 の一覧 FormPageを返します。

beginRecognizeContentFromUrl

public SyncPoller<>> beginRecognizeContentFromUrl(String formUrl)

光学式文字認識 (OCR) を使用して、ドキュメントのコンテンツ/レイアウト データを認識します。

このサービスは、実行時間の長い操作の取り消しをサポートせず、取り消しサポートがないことを示すエラー メッセージを返します。

Code sample

String formUrl = "{form_url}";
 formRecognizerClient.beginRecognizeContentFromUrl(formUrl)
     .getFinalResult()
     .forEach(formPage -> {
         System.out.printf("Page Angle: %s%n", formPage.getTextAngle());
         System.out.printf("Page Dimension unit: %s%n", formPage.getUnit());
         // Table information
         System.out.println("Recognized Tables: ");
         formPage.getTables()
             .stream()
             .flatMap(formTable -> formTable.getCells().stream())
             .forEach(recognizedTableCell -> System.out.printf("%s ", recognizedTableCell.getText()));
     });

Parameters:

formUrl - 分析するフォームの URL。

Returns:

SyncPoller<T,U>完了、失敗、または取り消されるまで、コンテンツ認識フォーム操作をポーリングする 。 完了した操作は、 の一覧 FormPageを返します。

beginRecognizeContentFromUrl

public SyncPoller<>> beginRecognizeContentFromUrl(String formUrl, RecognizeContentOptions recognizeContentOptions, Context context)

光学式文字認識 (OCR) を使用してコンテンツ/レイアウト データを認識します。

このサービスは、実行時間の長い操作の取り消しをサポートせず、取り消しサポートがないことを示すエラー メッセージを返します。

コンテンツ認識では、自動言語識別と多言語ドキュメントがサポートされているため、 でドキュメントを特定の言語として処理するように強制する場合にのみ言語コードを RecognizeContentOptions提供します。

Code sample

String formPath = "{file_source_url}";
 formRecognizerClient.beginRecognizeContentFromUrl(formPath,
     new RecognizeContentOptions()
         .setPollInterval(Duration.ofSeconds(5)), Context.NONE)
     .getFinalResult()
     .forEach(formPage -> {
         System.out.printf("Page Angle: %s%n", formPage.getTextAngle());
         System.out.printf("Page Dimension unit: %s%n", formPage.getUnit());
         // Table information
         System.out.println("Recognized Tables: ");
         formPage.getTables()
             .stream()
             .flatMap(formTable -> formTable.getCells().stream())
             .forEach(recognizedTableCell -> System.out.printf("%s ", recognizedTableCell.getText()));
     });

Parameters:

formUrl - 入力フォームのソース URL。
recognizeContentOptions - フォーム上のコンテンツ/レイアウトを認識するときに渡される可能性がある追加の構成可能 RecognizeContentOptions
context - サービス呼び出し中に HTTP パイプラインを介して渡される追加のコンテキスト。

Returns:

SyncPoller<T,U>レイアウト認識操作が完了、失敗、または取り消されるまでポーリングする 。 完了した操作は、 の一覧 FormPageを返します。

beginRecognizeCustomForms

public SyncPoller<>> beginRecognizeCustomForms(String modelId, InputStream form, long length)

光学式文字認識 (OCR) と、ラベル付きまたはラベルなしのカスタムトレーニング済みモデルを使用して、ドキュメントからフォーム データを認識します。

このサービスは、実行時間の長い操作の取り消しをサポートせず、取り消しサポートがないことを示すエラー メッセージを返します。

Code sample

File form = new File("{local/file_path/fileName.jpg}");
 String modelId = "{custom_trained_model_id}";
 byte[] fileContent = Files.readAllBytes(form.toPath());
 try (InputStream targetStream = new ByteArrayInputStream(fileContent)) {

     formRecognizerClient.beginRecognizeCustomForms(modelId, targetStream, form.length())
         .getFinalResult()
         .stream()
         .map(RecognizedForm::getFields)
         .forEach(formFieldMap -> formFieldMap.forEach((fieldText, formField) -> {
             System.out.printf("Field text: %s%n", fieldText);
             System.out.printf("Field value data text: %s%n", formField.getValueData().getText());
             System.out.printf("Confidence score: %.2f%n", formField.getConfidence());
         }));
 }

Parameters:

modelId - 使用する UUID 文字列形式のカスタム トレーニング済みモデル ID。
form - フォーム情報を認識するフォームのデータ。
length - データの正確な長さ。

Returns:

SyncPoller<T,U>完了、失敗、または取り消されるまで、認識カスタム フォーム操作をポーリングする 。 完了した操作は、 の一覧 RecognizedFormを返します。

beginRecognizeCustomForms

public SyncPoller<>> beginRecognizeCustomForms(String modelId, InputStream form, long length, RecognizeCustomFormsOptions recognizeCustomFormsOptions, Context context)

光学式文字認識 (OCR) とカスタムトレーニング済みモデルを使用して、ドキュメントからフォーム データを認識します。

このサービスは、実行時間の長い操作の取り消しをサポートせず、取り消しサポートがないことを示すエラー メッセージを返します。

Code sample

File form = new File("{local/file_path/fileName.jpg}");
 String modelId = "{custom_trained_model_id}";
 boolean includeFieldElements = true;
 byte[] fileContent = Files.readAllBytes(form.toPath());

 try (InputStream targetStream = new ByteArrayInputStream(fileContent)) {
     formRecognizerClient.beginRecognizeCustomForms(modelId, targetStream, form.length(),
         new RecognizeCustomFormsOptions()
             .setContentType(FormContentType.IMAGE_JPEG)
             .setFieldElementsIncluded(includeFieldElements)
             .setPollInterval(Duration.ofSeconds(10)), Context.NONE)
         .getFinalResult()
         .stream()
         .map(RecognizedForm::getFields)
         .forEach(formFieldMap -> formFieldMap.forEach((fieldText, formField) -> {
             System.out.printf("Field text: %s%n", fieldText);
             System.out.printf("Field value data text: %s%n", formField.getValueData().getText());
             System.out.printf("Confidence score: %.2f%n", formField.getConfidence());
         }));
 }

Parameters:

modelId - 使用する UUID 文字列形式のカスタム トレーニング済みモデル ID。
form - フォーム情報を認識するフォームのデータ。
length - データの正確な長さ。
recognizeCustomFormsOptions - カスタム フォームを認識するときに渡される可能性がある追加の構成可能 RecognizeCustomFormsOptions
context - サービス呼び出し中に HTTP パイプラインを介して渡される追加のコンテキスト。

Returns:

SyncPoller<T,U>完了、失敗、または取り消されるまで、認識カスタム フォーム操作をポーリングする 。 完了した操作は、 の一覧 RecognizedFormを返します。

beginRecognizeCustomFormsFromUrl

public SyncPoller<>> beginRecognizeCustomFormsFromUrl(String modelId, String formUrl)

光学式文字認識 (OCR) と、ラベル付きまたはラベルなしのカスタムトレーニング済みモデルを使用して、ドキュメントからフォーム データを認識します。

サービスは実行時間の長い操作の取り消しをサポートせず、取り消しサポートがないことを示すエラー メッセージを返します

Code sample

String formUrl = "{form_url}";
 String modelId = "{custom_trained_model_id}";

 formRecognizerClient.beginRecognizeCustomFormsFromUrl(modelId, formUrl).getFinalResult()
     .stream()
     .map(RecognizedForm::getFields)
     .forEach(formFieldMap -> formFieldMap.forEach((fieldText, formField) -> {
         System.out.printf("Field text: %s%n", fieldText);
         System.out.printf("Field value data text: %s%n", formField.getValueData().getText());
         System.out.printf("Confidence score: %.2f%n", formField.getConfidence());
     }));

Parameters:

modelId - 使用する UUID 文字列形式のカスタム トレーニング済みモデル ID。
formUrl - 分析するフォームの URL。

Returns:

SyncPoller<T,U>完了、失敗、または取り消されるまで、カスタム フォーム認識操作の進行状況をポーリングする 。 完了した操作は、 の一覧 RecognizedFormを返します。

beginRecognizeCustomFormsFromUrl

public SyncPoller<>> beginRecognizeCustomFormsFromUrl(String modelId, String formUrl, RecognizeCustomFormsOptions recognizeCustomFormsOptions, Context context)

光学式文字認識 (OCR) とカスタムトレーニング済みモデルを使用して、ドキュメントからフォーム データを認識します。

サービスは実行時間の長い操作の取り消しをサポートせず、取り消しサポートがないことを示すエラー メッセージを返します

Code sample

String analyzeFilePath = "{file_source_url}";
 String modelId = "{model_id}";
 boolean includeFieldElements = true;

 formRecognizerClient.beginRecognizeCustomFormsFromUrl(modelId, analyzeFilePath,
     new RecognizeCustomFormsOptions()
         .setFieldElementsIncluded(includeFieldElements)
         .setPollInterval(Duration.ofSeconds(10)), Context.NONE)
     .getFinalResult()
     .stream()
     .map(RecognizedForm::getFields)
     .forEach(formFieldMap -> formFieldMap.forEach((fieldText, formField) -> {
         System.out.printf("Field text: %s%n", fieldText);
         System.out.printf("Field value data text: %s%n", formField.getValueData().getText());
         System.out.printf("Confidence score: %.2f%n", formField.getConfidence());
     }));

Parameters:

modelId - 使用する UUID 文字列形式のカスタム トレーニング済みモデル ID。
formUrl - 入力フォームのソース URL。
recognizeCustomFormsOptions - カスタム フォームを認識するときに渡される可能性がある追加の構成可能 RecognizeCustomFormsOptions
context - サービス呼び出し中に HTTP パイプラインを介して渡される追加のコンテキスト。

Returns:

SyncPoller<T,U>完了、失敗、または取り消されるまで、カスタム フォーム認識操作の進行状況をポーリングする 。 完了した操作は、 の一覧 RecognizedFormを返します。

beginRecognizeIdentityDocuments

public SyncPoller<>> beginRecognizeIdentityDocuments(InputStream identityDocument, long length)

光学式文字認識 (OCR) と ID ドキュメント モデルでトレーニングされた事前構築済みモデルを使用して ID ドキュメントを分析し、パスポートと米国の運転免許証から重要な情報を抽出します。 ID ドキュメントで見つかったフィールドについては、 こちらを 参照してください。

サービスは実行時間の長い操作の取り消しをサポートせず、取り消しサポートがないことを示すエラー メッセージを返します

Code sample

File license = new File("local/file_path/license.jpg");
 ByteArrayInputStream inputStream = new ByteArrayInputStream(Files.readAllBytes(license.toPath()));
 // if training polling operation completed, retrieve the final result.
 formRecognizerClient.beginRecognizeIdentityDocuments(inputStream, license.length())
     .getFinalResult()
     .stream()
     .map(RecognizedForm::getFields)
     .forEach(recognizedFields -> {
         FormField firstNameField = recognizedFields.get("FirstName");
         if (firstNameField != null) {
             if (FieldValueType.STRING == firstNameField.getValue().getValueType()) {
                 String firstName = firstNameField.getValue().asString();
                 System.out.printf("First Name: %s, confidence: %.2f%n",
                     firstName, firstNameField.getConfidence());
             }
         }

         FormField lastNameField = recognizedFields.get("LastName");
         if (lastNameField != null) {
             if (FieldValueType.STRING == lastNameField.getValue().getValueType()) {
                 String lastName = lastNameField.getValue().asString();
                 System.out.printf("Last name: %s, confidence: %.2f%n",
                     lastName, lastNameField.getConfidence());
             }
         }

         FormField countryRegionFormField = recognizedFields.get("CountryRegion");
         if (countryRegionFormField != null) {
             if (FieldValueType.STRING == countryRegionFormField.getValue().getValueType()) {
                 String countryRegion = countryRegionFormField.getValue().asCountryRegion();
                 System.out.printf("Country or region: %s, confidence: %.2f%n",
                     countryRegion, countryRegionFormField.getConfidence());
             }
         }

         FormField dateOfExpirationField = recognizedFields.get("DateOfExpiration");
         if (dateOfExpirationField != null) {
             if (FieldValueType.DATE == dateOfExpirationField.getValue().getValueType()) {
                 LocalDate expirationDate = dateOfExpirationField.getValue().asDate();
                 System.out.printf("Document date of expiration: %s, confidence: %.2f%n",
                     expirationDate, dateOfExpirationField.getConfidence());
             }
         }

         FormField documentNumberField = recognizedFields.get("DocumentNumber");
         if (documentNumberField != null) {
             if (FieldValueType.STRING == documentNumberField.getValue().getValueType()) {
                 String documentNumber = documentNumberField.getValue().asString();
                 System.out.printf("Document number: %s, confidence: %.2f%n",
                     documentNumber, documentNumberField.getConfidence());
             }
         }
     });

Parameters:

identityDocument - ID ドキュメント情報を認識する ID ドキュメントのデータ。
length - データの正確な長さ。

Returns:

SyncPoller<T,U>完了、失敗、または取り消されるまで、ID ドキュメント認識操作をポーリングする 。 完了した操作は、 の一覧 RecognizedFormを返します。

beginRecognizeIdentityDocuments

public SyncPoller<>> beginRecognizeIdentityDocuments(InputStream identityDocument, long length, RecognizeIdentityDocumentOptions recognizeIdentityDocumentOptions, Context context)

光学式文字認識 (OCR) と ID ドキュメント モデルでトレーニングされた事前構築済みモデルを使用して ID ドキュメントを分析し、パスポートと米国の運転免許証から重要な情報を抽出します。 ID ドキュメントで見つかったフィールドについては、 こちらを 参照してください。

サービスは実行時間の長い操作の取り消しをサポートせず、取り消しサポートがないことを示すエラー メッセージを返します

Code sample

File licenseDocument = new File("local/file_path/license.jpg");
 boolean includeFieldElements = true;
 // Utility method to convert input stream to Byte buffer
 ByteArrayInputStream inputStream = new ByteArrayInputStream(Files.readAllBytes(licenseDocument.toPath()));
 // if training polling operation completed, retrieve the final result.
 formRecognizerClient.beginRecognizeIdentityDocuments(inputStream,
     licenseDocument.length(),
     new RecognizeIdentityDocumentOptions()
         .setContentType(FormContentType.IMAGE_JPEG)
         .setFieldElementsIncluded(includeFieldElements),
     Context.NONE)
     .setPollInterval(Duration.ofSeconds(5))
     .getFinalResult()
     .stream()
     .map(RecognizedForm::getFields)
     .forEach(recognizedFields -> {
         FormField firstNameField = recognizedFields.get("FirstName");
         if (firstNameField != null) {
             if (FieldValueType.STRING == firstNameField.getValue().getValueType()) {
                 String firstName = firstNameField.getValue().asString();
                 System.out.printf("First Name: %s, confidence: %.2f%n",
                     firstName, firstNameField.getConfidence());
             }
         }

         FormField lastNameField = recognizedFields.get("LastName");
         if (lastNameField != null) {
             if (FieldValueType.STRING == lastNameField.getValue().getValueType()) {
                 String lastName = lastNameField.getValue().asString();
                 System.out.printf("Last name: %s, confidence: %.2f%n",
                     lastName, lastNameField.getConfidence());
             }
         }

         FormField countryRegionFormField = recognizedFields.get("CountryRegion");
         if (countryRegionFormField != null) {
             if (FieldValueType.STRING == countryRegionFormField.getValue().getValueType()) {
                 String countryRegion = countryRegionFormField.getValue().asCountryRegion();
                 System.out.printf("Country or region: %s, confidence: %.2f%n",
                     countryRegion, countryRegionFormField.getConfidence());
             }
         }

         FormField dateOfBirthField = recognizedFields.get("DateOfBirth");
         if (dateOfBirthField != null) {
             if (FieldValueType.DATE == dateOfBirthField.getValue().getValueType()) {
                 LocalDate dateOfBirth = dateOfBirthField.getValue().asDate();
                 System.out.printf("Date of Birth: %s, confidence: %.2f%n",
                     dateOfBirth, dateOfBirthField.getConfidence());
             }
         }

         FormField dateOfExpirationField = recognizedFields.get("DateOfExpiration");
         if (dateOfExpirationField != null) {
             if (FieldValueType.DATE == dateOfExpirationField.getValue().getValueType()) {
                 LocalDate expirationDate = dateOfExpirationField.getValue().asDate();
                 System.out.printf("Document date of expiration: %s, confidence: %.2f%n",
                     expirationDate, dateOfExpirationField.getConfidence());
             }
         }

         FormField documentNumberField = recognizedFields.get("DocumentNumber");
         if (documentNumberField != null) {
             if (FieldValueType.STRING == documentNumberField.getValue().getValueType()) {
                 String documentNumber = documentNumberField.getValue().asString();
                 System.out.printf("Document number: %s, confidence: %.2f%n",
                     documentNumber, documentNumberField.getConfidence());
             }
         }
     });

Parameters:

identityDocument - 情報を認識する ID ドキュメントのデータ。
length - データの正確な長さ。
recognizeIdentityDocumentOptions - ID ドキュメントを分析するときに渡される可能性がある追加の構成可能 RecognizeIdentityDocumentOptions
context - サービス呼び出し中に HTTP パイプラインを介して渡される追加のコンテキスト。

Returns:

SyncPoller<T,U>完了、失敗、または取り消されるまで、認識 ID ドキュメント操作をポーリングする 。 完了した操作は、 の一覧 RecognizedFormを返します。

beginRecognizeIdentityDocumentsFromUrl

public SyncPoller<>> beginRecognizeIdentityDocumentsFromUrl(String identityDocumentUrl)

光学式文字認識 (OCR) と ID ドキュメント モデルでトレーニングされた事前構築済みモデルを使用して ID ドキュメントを分析し、パスポートと米国の運転免許証から重要な情報を抽出します。 ID ドキュメントで見つかったフィールドについては、 こちらを 参照してください。

サービスは実行時間の長い操作の取り消しをサポートせず、取り消しサポートがないことを示すエラー メッセージを返します

Code sample

String licenseDocumentUrl = "licenseDocumentUrl";
 // if training polling operation completed, retrieve the final result.
 formRecognizerClient.beginRecognizeIdentityDocumentsFromUrl(licenseDocumentUrl)
     .getFinalResult()
     .stream()
     .map(RecognizedForm::getFields)
     .forEach(recognizedFields -> {
         FormField firstNameField = recognizedFields.get("FirstName");
         if (firstNameField != null) {
             if (FieldValueType.STRING == firstNameField.getValue().getValueType()) {
                 String firstName = firstNameField.getValue().asString();
                 System.out.printf("First Name: %s, confidence: %.2f%n",
                     firstName, firstNameField.getConfidence());
             }
         }

         FormField lastNameField = recognizedFields.get("LastName");
         if (lastNameField != null) {
             if (FieldValueType.STRING == lastNameField.getValue().getValueType()) {
                 String lastName = lastNameField.getValue().asString();
                 System.out.printf("Last name: %s, confidence: %.2f%n",
                     lastName, lastNameField.getConfidence());
             }
         }

         FormField countryRegionFormField = recognizedFields.get("CountryRegion");
         if (countryRegionFormField != null) {
             if (FieldValueType.STRING == countryRegionFormField.getValue().getValueType()) {
                 String countryRegion = countryRegionFormField.getValue().asCountryRegion();
                 System.out.printf("Country or region: %s, confidence: %.2f%n",
                     countryRegion, countryRegionFormField.getConfidence());
             }
         }

         FormField dateOfBirthField = recognizedFields.get("DateOfBirth");
         if (dateOfBirthField != null) {
             if (FieldValueType.DATE == dateOfBirthField.getValue().getValueType()) {
                 LocalDate dateOfBirth = dateOfBirthField.getValue().asDate();
                 System.out.printf("Date of Birth: %s, confidence: %.2f%n",
                     dateOfBirth, dateOfBirthField.getConfidence());
             }
         }

         FormField dateOfExpirationField = recognizedFields.get("DateOfExpiration");
         if (dateOfExpirationField != null) {
             if (FieldValueType.DATE == dateOfExpirationField.getValue().getValueType()) {
                 LocalDate expirationDate = dateOfExpirationField.getValue().asDate();
                 System.out.printf("Document date of expiration: %s, confidence: %.2f%n",
                     expirationDate, dateOfExpirationField.getConfidence());
             }
         }

         FormField documentNumberField = recognizedFields.get("DocumentNumber");
         if (documentNumberField != null) {
             if (FieldValueType.STRING == documentNumberField.getValue().getValueType()) {
                 String documentNumber = documentNumberField.getValue().asString();
                 System.out.printf("Document number: %s, confidence: %.2f%n",
                     documentNumber, documentNumberField.getConfidence());
             }
         }
     });

Parameters:

identityDocumentUrl - 入力 ID ドキュメントのソース URL。

Returns:

SyncPoller<T,U>完了、失敗、または取り消されるまで、ID 認識ドキュメント操作の進行状況をポーリングする 。 完了した操作は、 の一覧 RecognizedFormを返します。

beginRecognizeIdentityDocumentsFromUrl

public SyncPoller<>> beginRecognizeIdentityDocumentsFromUrl(String identityDocumentUrl, RecognizeIdentityDocumentOptions recognizeIdentityDocumentOptions, Context context)

光学式文字認識 (OCR) と ID ドキュメント モデルでトレーニングされた事前構築済みモデルを使用して ID ドキュメントを分析し、パスポートと米国の運転免許証から重要な情報を抽出します。 ID ドキュメントで見つかったフィールドについては、 こちらを 参照してください。

サービスは実行時間の長い操作の取り消しをサポートせず、取り消しサポートがないことを示すエラー メッセージを返します

Code sample

String licenseDocumentUrl = "licenseDocumentUrl";
 boolean includeFieldElements = true;
 // if training polling operation completed, retrieve the final result.
 formRecognizerClient.beginRecognizeIdentityDocumentsFromUrl(licenseDocumentUrl,
     new RecognizeIdentityDocumentOptions()
         .setFieldElementsIncluded(includeFieldElements),
     Context.NONE).setPollInterval(Duration.ofSeconds(5))
     .getFinalResult()
     .stream()
     .map(RecognizedForm::getFields)
     .forEach(recognizedFields -> {
         FormField firstNameField = recognizedFields.get("FirstName");
         if (firstNameField != null) {
             if (FieldValueType.STRING == firstNameField.getValue().getValueType()) {
                 String firstName = firstNameField.getValue().asString();
                 System.out.printf("First Name: %s, confidence: %.2f%n",
                     firstName, firstNameField.getConfidence());
             }
         }

         FormField lastNameField = recognizedFields.get("LastName");
         if (lastNameField != null) {
             if (FieldValueType.STRING == lastNameField.getValue().getValueType()) {
                 String lastName = lastNameField.getValue().asString();
                 System.out.printf("Last name: %s, confidence: %.2f%n",
                     lastName, lastNameField.getConfidence());
             }
         }

         FormField countryRegionFormField = recognizedFields.get("CountryRegion");
         if (countryRegionFormField != null) {
             if (FieldValueType.STRING == countryRegionFormField.getValue().getValueType()) {
                 String countryRegion = countryRegionFormField.getValue().asCountryRegion();
                 System.out.printf("Country or region: %s, confidence: %.2f%n",
                     countryRegion, countryRegionFormField.getConfidence());
             }
         }

         FormField dateOfExpirationField = recognizedFields.get("DateOfExpiration");
         if (dateOfExpirationField != null) {
             if (FieldValueType.DATE == dateOfExpirationField.getValue().getValueType()) {
                 LocalDate expirationDate = dateOfExpirationField.getValue().asDate();
                 System.out.printf("Document date of expiration: %s, confidence: %.2f%n",
                     expirationDate, dateOfExpirationField.getConfidence());
             }
         }

         FormField documentNumberField = recognizedFields.get("DocumentNumber");
         if (documentNumberField != null) {
             if (FieldValueType.STRING == documentNumberField.getValue().getValueType()) {
                 String documentNumber = documentNumberField.getValue().asString();
                 System.out.printf("Document number: %s, confidence: %.2f%n",
                     documentNumber, documentNumberField.getConfidence());
             }
         }
     });

Parameters:

identityDocumentUrl - 入力 ID ドキュメントのソース URL。
recognizeIdentityDocumentOptions - ID ドキュメントを分析するときに渡される可能性がある追加の構成可能 RecognizeIdentityDocumentOptions
context - サービス呼び出し中に HTTP パイプラインを介して渡される追加のコンテキスト。

Returns:

SyncPoller<T,U>完了、失敗、または取り消されるまで、ID 認識ドキュメント操作の進行状況をポーリングする 。 完了した操作は、 の一覧 RecognizedFormを返します。

beginRecognizeInvoices

public SyncPoller<>> beginRecognizeInvoices(InputStream invoice, long length)

光学式文字認識 (OCR) と事前構築済みのトレーニング済み請求書モデルを使用して、指定されたドキュメント データのデータを認識します。

サービスは実行時間の長い操作の取り消しをサポートせず、取り消しサポートがないことを示すエラー メッセージを返します

請求書で見つかったフィールドについては、 こちらを 参照してください。

Code sample

File invoice = new File("local/file_path/invoice.jpg");
 ByteArrayInputStream inputStream = new ByteArrayInputStream(Files.readAllBytes(invoice.toPath()));
 // if training polling operation completed, retrieve the final result.
 formRecognizerClient.beginRecognizeInvoices(inputStream, invoice.length())
     .getFinalResult()
     .stream()
     .map(RecognizedForm::getFields)
     .forEach(recognizedFields -> {
         FormField customAddrFormField = recognizedFields.get("CustomerAddress");
         if (customAddrFormField != null) {
             if (FieldValueType.STRING == customAddrFormField.getValue().getValueType()) {
                 System.out.printf("Customer Address: %s%n", customAddrFormField.getValue().asString());
             }
         }
         FormField invoiceDateFormField = recognizedFields.get("InvoiceDate");
         if (invoiceDateFormField != null) {
             if (FieldValueType.DATE == invoiceDateFormField.getValue().getValueType()) {
                 LocalDate invoiceDate = invoiceDateFormField.getValue().asDate();
                 System.out.printf("Invoice Date: %s, confidence: %.2f%n",
                     invoiceDate, invoiceDateFormField.getConfidence());
             }
         }
     });

Parameters:

invoice - 請求書関連情報を認識する請求書のデータ。
length - データの正確な長さ。

Returns:

SyncPoller<T,U>完了、失敗、または取り消されるまで、認識請求書操作をポーリングする 。 完了した操作は、 の一覧 RecognizedFormを返します。

beginRecognizeInvoices

public SyncPoller<>> beginRecognizeInvoices(InputStream invoice, long length, RecognizeInvoicesOptions recognizeInvoicesOptions, Context context)

光学式文字認識 (OCR) と事前構築済みのトレーニング済み請求書モデルを使用して、指定されたドキュメント データのデータを認識します。

サービスは実行時間の長い操作の取り消しをサポートせず、取り消しサポートがないことを示すエラー メッセージを返します

請求書で見つかったフィールドについては、 こちらを 参照してください。

Code sample

File invoice = new File("local/file_path/invoice.jpg");
 boolean includeFieldElements = true;
 // Utility method to convert input stream to Byte buffer
 ByteArrayInputStream inputStream = new ByteArrayInputStream(Files.readAllBytes(invoice.toPath()));
 // if training polling operation completed, retrieve the final result.
 formRecognizerClient.beginRecognizeInvoices(inputStream,
     invoice.length(),
     new RecognizeInvoicesOptions()
         .setContentType(FormContentType.IMAGE_JPEG)
         .setFieldElementsIncluded(includeFieldElements),
     Context.NONE)
     .setPollInterval(Duration.ofSeconds(5))
     .getFinalResult()
     .stream()
     .map(RecognizedForm::getFields)
     .forEach(recognizedFields -> {
         FormField customAddrFormField = recognizedFields.get("CustomerAddress");
         if (customAddrFormField != null) {
             if (FieldValueType.STRING == customAddrFormField.getValue().getValueType()) {
                 System.out.printf("Customer Address: %s%n", customAddrFormField.getValue().asString());
             }
         }
         FormField invoiceDateFormField = recognizedFields.get("InvoiceDate");
         if (invoiceDateFormField != null) {
             if (FieldValueType.DATE == invoiceDateFormField.getValue().getValueType()) {
                 LocalDate invoiceDate = invoiceDateFormField.getValue().asDate();
                 System.out.printf("Invoice Date: %s, confidence: %.2f%n",
                     invoiceDate, invoiceDateFormField.getConfidence());
             }
         }
     });

Parameters:

invoice - 請求書関連情報を認識する請求書のデータ。
length - データの正確な長さ。
recognizeInvoicesOptions - 請求書を分析するときに渡される可能性がある追加の構成可能 RecognizeInvoicesOptions
context - サービス呼び出し中に HTTP パイプラインを介して渡される追加のコンテキスト。

Returns:

SyncPoller<T,U>完了、失敗、または取り消されるまで、認識請求書操作をポーリングする 。 完了した操作は、 の一覧 RecognizedFormを返します。

beginRecognizeInvoicesFromUrl

public SyncPoller<>> beginRecognizeInvoicesFromUrl(String invoiceUrl)

光学式文字認識 (OCR) と事前構築済みの請求書トレーニング済みモデルを使用して、ドキュメントからの請求書データを認識します。

サービスは実行時間の長い操作の取り消しをサポートせず、取り消しサポートがないことを示すエラー メッセージを返します

請求書で見つかったフィールドについては、 こちらを 参照してください。

Code sample

String invoiceUrl = "invoice_url";
 // if training polling operation completed, retrieve the final result.
 formRecognizerClient.beginRecognizeInvoicesFromUrl(invoiceUrl)
     .getFinalResult()
     .stream()
     .map(RecognizedForm::getFields)
     .forEach(recognizedFields -> {
         FormField customAddrFormField = recognizedFields.get("CustomerAddress");
         if (customAddrFormField != null) {
             if (FieldValueType.STRING == customAddrFormField.getValue().getValueType()) {
                 System.out.printf("Customer Address: %s%n", customAddrFormField.getValue().asString());
             }
         }
         FormField invoiceDateFormField = recognizedFields.get("InvoiceDate");
         if (invoiceDateFormField != null) {
             if (FieldValueType.DATE == invoiceDateFormField.getValue().getValueType()) {
                 LocalDate invoiceDate = invoiceDateFormField.getValue().asDate();
                 System.out.printf("Invoice Date: %s, confidence: %.2f%n",
                     invoiceDate, invoiceDateFormField.getConfidence());
             }
         }
     });

Parameters:

invoiceUrl - 分析する請求書ドキュメントの URL。

Returns:

SyncPoller<T,U>完了、失敗、または取り消されるまで、請求書認識操作の進行状況をポーリングする 。 完了した操作は、 の一覧 RecognizedFormを返します。

beginRecognizeInvoicesFromUrl

public SyncPoller<>> beginRecognizeInvoicesFromUrl(String invoiceUrl, RecognizeInvoicesOptions recognizeInvoicesOptions, Context context)

光学式文字認識 (OCR) と事前構築済みの請求書トレーニング済みモデルを使用して、ドキュメントからの請求書データを認識します。

サービスは実行時間の長い操作の取り消しをサポートせず、取り消しサポートがないことを示すエラー メッセージを返します

Code sample

String invoiceUrl = "invoice_url";
 boolean includeFieldElements = true;
 // if training polling operation completed, retrieve the final result.
 formRecognizerClient.beginRecognizeInvoicesFromUrl(invoiceUrl,
     new RecognizeInvoicesOptions()
         .setFieldElementsIncluded(includeFieldElements),
     Context.NONE).setPollInterval(Duration.ofSeconds(5))
     .getFinalResult()
     .stream()
     .map(RecognizedForm::getFields)
     .forEach(recognizedFields -> {
         FormField customAddrFormField = recognizedFields.get("CustomerAddress");
         if (customAddrFormField != null) {
             if (FieldValueType.STRING == customAddrFormField.getValue().getValueType()) {
                 System.out.printf("Customer Address: %s%n", customAddrFormField.getValue().asString());
             }
         }
         FormField invoiceDateFormField = recognizedFields.get("InvoiceDate");
         if (invoiceDateFormField != null) {
             if (FieldValueType.DATE == invoiceDateFormField.getValue().getValueType()) {
                 LocalDate invoiceDate = invoiceDateFormField.getValue().asDate();
                 System.out.printf("Invoice Date: %s, confidence: %.2f%n",
                     invoiceDate, invoiceDateFormField.getConfidence());
             }
         }
     });

Parameters:

invoiceUrl - 入力請求書ドキュメントのソース URL。
recognizeInvoicesOptions - 請求書を分析するときに渡される可能性がある追加の構成可能 RecognizeInvoicesOptions
context - サービス呼び出し中に HTTP パイプラインを介して渡される追加のコンテキスト。

Returns:

SyncPoller<T,U>完了、失敗、または取り消されるまで、請求書認識操作の進行状況をポーリングする 。 完了した操作は、 の一覧 RecognizedFormを返します。

beginRecognizeReceipts

public SyncPoller<>> beginRecognizeReceipts(InputStream receipt, long length)

光学式文字認識 (OCR) と事前構築済みのトレーニング済みレシート モデルを使用して、指定されたドキュメント データのデータを認識します。

サービスは実行時間の長い操作の取り消しをサポートせず、取り消しサポートがないことを示すエラー メッセージを返します

領収書で見つかったフィールドについては、 こちらを 参照してください。

Code sample

File receipt = new File("{receipt_url}");
 byte[] fileContent = Files.readAllBytes(receipt.toPath());
 try (InputStream targetStream = new ByteArrayInputStream(fileContent)) {

     formRecognizerClient.beginRecognizeReceipts(targetStream, receipt.length()).getFinalResult()
         .forEach(recognizedReceipt -> {
             Map<String, FormField> recognizedFields = recognizedReceipt.getFields();
             FormField merchantNameField = recognizedFields.get("MerchantName");
             if (merchantNameField != null) {
                 if (FieldValueType.STRING == merchantNameField.getValue().getValueType()) {
                     String merchantName = merchantNameField.getValue().asString();
                     System.out.printf("Merchant Name: %s, confidence: %.2f%n",
                         merchantName, merchantNameField.getConfidence());
                 }
             }

             FormField merchantPhoneNumberField = recognizedFields.get("MerchantPhoneNumber");
             if (merchantPhoneNumberField != null) {
                 if (FieldValueType.PHONE_NUMBER == merchantPhoneNumberField.getValue().getValueType()) {
                     String merchantAddress = merchantPhoneNumberField.getValue().asPhoneNumber();
                     System.out.printf("Merchant Phone number: %s, confidence: %.2f%n",
                         merchantAddress, merchantPhoneNumberField.getConfidence());
                 }
             }

             FormField transactionDateField = recognizedFields.get("TransactionDate");
             if (transactionDateField != null) {
                 if (FieldValueType.DATE == transactionDateField.getValue().getValueType()) {
                     LocalDate transactionDate = transactionDateField.getValue().asDate();
                     System.out.printf("Transaction Date: %s, confidence: %.2f%n",
                         transactionDate, transactionDateField.getConfidence());
                 }
             }

             FormField receiptItemsField = recognizedFields.get("Items");
             if (receiptItemsField != null) {
                 System.out.printf("Receipt Items: %n");
                 if (FieldValueType.LIST == receiptItemsField.getValue().getValueType()) {
                     List<FormField> receiptItems = receiptItemsField.getValue().asList();
                     receiptItems.stream()
                         .filter(receiptItem -> FieldValueType.MAP == receiptItem.getValue().getValueType())
                         .map(formField -> formField.getValue().asMap())
                         .forEach(formFieldMap -> formFieldMap.forEach((key, formField) -> {
                             if ("Quantity".equals(key)) {
                                 if (FieldValueType.FLOAT == formField.getValue().getValueType()) {
                                     Float quantity = formField.getValue().asFloat();
                                     System.out.printf("Quantity: %f, confidence: %.2f%n",
                                         quantity, formField.getConfidence());
                                 }
                             }
                         }));
                 }
             }
         });
 }

Parameters:

receipt - レシート情報を認識するレシートのデータ。
length - データの正確な長さ。

Returns:

SyncPoller<T,U>完了、失敗、または取り消されるまで、受信確認操作をポーリングする 。 完了した操作は、 の一覧 RecognizedFormを返します。

beginRecognizeReceipts

public SyncPoller<>> beginRecognizeReceipts(InputStream receipt, long length, RecognizeReceiptsOptions recognizeReceiptsOptions, Context context)

光学式文字認識 (OCR) と事前構築済みのトレーニング済みレシート モデルを使用して、指定されたドキュメント データのデータを認識します。

サービスは実行時間の長い操作の取り消しをサポートせず、取り消しサポートがないことを示すエラー メッセージを返します

領収書で見つかったフィールドについては、 こちらを 参照してください。

Code sample

File receipt = new File("{local/file_path/fileName.jpg}");
 boolean includeFieldElements = true;
 byte[] fileContent = Files.readAllBytes(receipt.toPath());
 try (InputStream targetStream = new ByteArrayInputStream(fileContent)) {
     for (RecognizedForm recognizedForm : formRecognizerClient
         .beginRecognizeReceipts(targetStream, receipt.length(),
             new RecognizeReceiptsOptions()
                 .setContentType(FormContentType.IMAGE_JPEG)
                 .setFieldElementsIncluded(includeFieldElements)
                 .setLocale(FormRecognizerLocale.EN_US)
                 .setPollInterval(Duration.ofSeconds(5)), Context.NONE)
         .getFinalResult()) {
         Map<String, FormField> recognizedFields = recognizedForm.getFields();
         FormField merchantNameField = recognizedFields.get("MerchantName");
         if (merchantNameField != null) {
             if (FieldValueType.STRING == merchantNameField.getValue().getValueType()) {
                 String merchantName = merchantNameField.getValue().asString();
                 System.out.printf("Merchant Name: %s, confidence: %.2f%n",
                     merchantName, merchantNameField.getConfidence());
             }
         }
         FormField merchantPhoneNumberField = recognizedFields.get("MerchantPhoneNumber");
         if (merchantPhoneNumberField != null) {
             if (FieldValueType.PHONE_NUMBER == merchantPhoneNumberField.getValue().getValueType()) {
                 String merchantAddress = merchantPhoneNumberField.getValue().asPhoneNumber();
                 System.out.printf("Merchant Phone number: %s, confidence: %.2f%n",
                     merchantAddress, merchantPhoneNumberField.getConfidence());
             }
         }
         FormField transactionDateField = recognizedFields.get("TransactionDate");
         if (transactionDateField != null) {
             if (FieldValueType.DATE == transactionDateField.getValue().getValueType()) {
                 LocalDate transactionDate = transactionDateField.getValue().asDate();
                 System.out.printf("Transaction Date: %s, confidence: %.2f%n",
                     transactionDate, transactionDateField.getConfidence());
             }
         }
         FormField receiptItemsField = recognizedFields.get("Items");
         if (receiptItemsField != null) {
             System.out.printf("Receipt Items: %n");
             if (FieldValueType.LIST == receiptItemsField.getValue().getValueType()) {
                 List<FormField> receiptItems = receiptItemsField.getValue().asList();
                 receiptItems.stream()
                     .filter(receiptItem -> FieldValueType.MAP == receiptItem.getValue().getValueType())
                     .map(formField -> formField.getValue().asMap())
                     .forEach(formFieldMap -> formFieldMap.forEach((key, formField) -> {
                         if ("Quantity".equals(key)) {
                             if (FieldValueType.FLOAT == formField.getValue().getValueType()) {
                                 Float quantity = formField.getValue().asFloat();
                                 System.out.printf("Quantity: %f, confidence: %.2f%n",
                                     quantity, formField.getConfidence());
                             }
                         }
                     }));
             }
         }
     }
 }

Parameters:

receipt - レシート情報を認識するレシートのデータ。
length - データの正確な長さ。
recognizeReceiptsOptions - 領収書を分析するときに渡される可能性がある追加の構成可能 RecognizeReceiptsOptions
context - サービス呼び出し中に HTTP パイプラインを介して渡される追加のコンテキスト。

Returns:

SyncPoller<T,U>完了、失敗、または取り消されるまで、受信確認操作をポーリングする 。 完了した操作は、 の一覧 RecognizedFormを返します。

beginRecognizeReceiptsFromUrl

public SyncPoller<>> beginRecognizeReceiptsFromUrl(String receiptUrl)

光学式文字認識 (OCR) と事前構築済みのレシートトレーニング済みモデルを使用して、ドキュメントからのレシート データを認識します。

サービスは実行時間の長い操作の取り消しをサポートせず、取り消しサポートがないことを示すエラー メッセージを返します

領収書で見つかったフィールドについては、 こちらを 参照してください。

Code sample

String receiptUrl = "{file_source_url}";
 formRecognizerClient.beginRecognizeReceiptsFromUrl(receiptUrl)
     .getFinalResult()
     .forEach(recognizedReceipt -> {
         Map<String, FormField> recognizedFields = recognizedReceipt.getFields();
         FormField merchantNameField = recognizedFields.get("MerchantName");
         if (merchantNameField != null) {
             if (FieldValueType.STRING == merchantNameField.getValue().getValueType()) {
                 String merchantName = merchantNameField.getValue().asString();
                 System.out.printf("Merchant Name: %s, confidence: %.2f%n",
                     merchantName, merchantNameField.getConfidence());
             }
         }

         FormField merchantPhoneNumberField = recognizedFields.get("MerchantPhoneNumber");
         if (merchantPhoneNumberField != null) {
             if (FieldValueType.PHONE_NUMBER == merchantPhoneNumberField.getValue().getValueType()) {
                 String merchantAddress = merchantPhoneNumberField.getValue().asPhoneNumber();
                 System.out.printf("Merchant Phone number: %s, confidence: %.2f%n",
                     merchantAddress, merchantPhoneNumberField.getConfidence());
             }
         }

         FormField transactionDateField = recognizedFields.get("TransactionDate");
         if (transactionDateField != null) {
             if (FieldValueType.DATE == transactionDateField.getValue().getValueType()) {
                 LocalDate transactionDate = transactionDateField.getValue().asDate();
                 System.out.printf("Transaction Date: %s, confidence: %.2f%n",
                     transactionDate, transactionDateField.getConfidence());
             }
         }

         FormField receiptItemsField = recognizedFields.get("Items");
         if (receiptItemsField != null) {
             System.out.printf("Receipt Items: %n");
             if (FieldValueType.LIST == receiptItemsField.getValue().getValueType()) {
                 List<FormField> receiptItems = receiptItemsField.getValue().asList();
                 receiptItems.stream()
                     .filter(receiptItem -> FieldValueType.MAP == receiptItem.getValue().getValueType())
                     .map(formField -> formField.getValue().asMap())
                     .forEach(formFieldMap -> formFieldMap.forEach((key, formField) -> {
                         if ("Quantity".equals(key)) {
                             if (FieldValueType.FLOAT == formField.getValue().getValueType()) {
                                 Float quantity = formField.getValue().asFloat();
                                 System.out.printf("Quantity: %f, confidence: %.2f%n",
                                     quantity, formField.getConfidence());
                             }
                         }
                     }));
             }
         }
     });

Parameters:

receiptUrl - 分析する領収書の URL。

Returns:

SyncPoller<T,U>完了、失敗、または取り消されるまで、受信確認操作の進行状況をポーリングする 。 完了した操作は、 の一覧 RecognizedFormを返します。

beginRecognizeReceiptsFromUrl

public SyncPoller<>> beginRecognizeReceiptsFromUrl(String receiptUrl, RecognizeReceiptsOptions recognizeReceiptsOptions, Context context)

光学式文字認識 (OCR) と事前構築済みのレシートトレーニング済みモデルを使用して、ドキュメントからのレシート データを認識します。

サービスは実行時間の長い操作の取り消しをサポートせず、取り消しサポートがないことを示すエラー メッセージを返します

Code sample

String receiptUrl = "{receipt_url}";
 formRecognizerClient.beginRecognizeReceiptsFromUrl(receiptUrl,
     new RecognizeReceiptsOptions()
         .setLocale(FormRecognizerLocale.EN_US)
         .setPollInterval(Duration.ofSeconds(5))
         .setFieldElementsIncluded(true), Context.NONE)
     .getFinalResult()
     .forEach(recognizedReceipt -> {
         Map<String, FormField> recognizedFields = recognizedReceipt.getFields();
         FormField merchantNameField = recognizedFields.get("MerchantName");
         if (merchantNameField != null) {
             if (FieldValueType.STRING == merchantNameField.getValue().getValueType()) {
                 String merchantName = merchantNameField.getValue().asString();
                 System.out.printf("Merchant Name: %s, confidence: %.2f%n",
                     merchantName, merchantNameField.getConfidence());
             }
         }

         FormField merchantPhoneNumberField = recognizedFields.get("MerchantPhoneNumber");
         if (merchantPhoneNumberField != null) {
             if (FieldValueType.PHONE_NUMBER == merchantPhoneNumberField.getValue().getValueType()) {
                 String merchantAddress = merchantPhoneNumberField.getValue().asPhoneNumber();
                 System.out.printf("Merchant Phone number: %s, confidence: %.2f%n",
                     merchantAddress, merchantPhoneNumberField.getConfidence());
             }
         }

         FormField transactionDateField = recognizedFields.get("TransactionDate");
         if (transactionDateField != null) {
             if (FieldValueType.DATE == transactionDateField.getValue().getValueType()) {
                 LocalDate transactionDate = transactionDateField.getValue().asDate();
                 System.out.printf("Transaction Date: %s, confidence: %.2f%n",
                     transactionDate, transactionDateField.getConfidence());
             }
         }

         FormField receiptItemsField = recognizedFields.get("Items");
         if (receiptItemsField != null) {
             System.out.printf("Receipt Items: %n");
             if (FieldValueType.LIST == receiptItemsField.getValue().getValueType()) {
                 List<FormField> receiptItems = receiptItemsField.getValue().asList();
                 receiptItems.stream()
                     .filter(receiptItem -> FieldValueType.MAP == receiptItem.getValue().getValueType())
                     .map(formField -> formField.getValue().asMap())
                     .forEach(formFieldMap -> formFieldMap.forEach((key, formField) -> {
                         if ("Quantity".equals(key)) {
                             if (FieldValueType.FLOAT == formField.getValue().getValueType()) {
                                 Float quantity = formField.getValue().asFloat();
                                 System.out.printf("Quantity: %f, confidence: %.2f%n",
                                     quantity, formField.getConfidence());
                             }
                         }
                     }));
             }
         }
     });

Parameters:

receiptUrl - 入力レシートのソース URL。
recognizeReceiptsOptions - 領収書を分析するときに渡される可能性がある追加の構成可能 RecognizeReceiptsOptions
context - サービス呼び出し中に HTTP パイプラインを介して渡される追加のコンテキスト。

Returns:

SyncPoller<T,U>完了、失敗、または取り消されるまで、受信確認操作の進行状況をポーリングする 。 完了した操作は、 の一覧 RecognizedFormを返します。

適用対象