DocumentAnalysisClient クラス
- java.
lang. Object - com.
azure. ai. formrecognizer. documentanalysis. DocumentAnalysisClient
- com.
public final class DocumentAnalysisClient
このクラスは、Form Recognizer Azure Cognitive Service に接続するための同期クライアントを提供します。
このクライアントは、次を実行する同期メソッドを提供します。
- カスタム ドキュメント分析: 個別のビジネス データとユース ケースに固有のフォームとドキュメントからのデータの分類、抽出、分析。 modelId を メソッドに渡して、カスタムトレーニング済みモデルを com.azure.ai.formrecognizer.documentanalysis.DocumentAnalysisClient#beginAnalyzeDocument(String, BinaryData) 使用します。
- 一般的なドキュメント分析: テキスト、テーブル、構造、およびキーと値のペアを抽出します。 modelId="rebuilt-document" を メソッドに渡して、Form Recognizer サービスによって提供される一般的なドキュメント モデルをcom.azure.ai.formrecognizer.documentanalysis.DocumentAnalysisClient#beginAnalyzeDocument(String, BinaryData)使用します。
- 事前構築済みモデル分析: 領収書、名刺、請求書、ID、W2、その他のドキュメントを使用して分析します supported prebuilt models. Use the prebuilt receipt model provided by passing modelId="prebuilt-receipt" into the com.azure.ai.formrecognizer.documentanalysis.DocumentAnalysisClient#beginAnalyzeDocument(String, BinaryData) method.
- レイアウト分析: テキスト、選択マーク、テーブル構造、および境界ボックス座標をフォームやドキュメントから抽出します。 modelId="prebuilt-layout" を メソッドに渡すことによって、サービスで提供されたレイアウト分析モデルを com.azure.ai.formrecognizer.documentanalysis.DocumentAnalysisClient#beginAnalyzeDocument(String, BinaryData) 使用します。
- ポーリングとコールバック: 分析操作の状態をチェックするためのサービスのポーリング、または分析が完了したときに通知を受信するためのコールバックの登録を行うメカニズムが含まれています。
このクライアントでは、URL からの入力とストリームからの入力に基づいて、さまざまなメソッドも提供されます。
メモ: このクライアントは 以降のみをサポートします V2022_08_31 。 以前のサービス バージョンと FormTrainingClientを使用するには。 FormRecognizerClient
サービス クライアントは、開発者が Azure Form Recognizerを使用するための対話のポイントです。 DocumentAnalysisClient は同期サービス クライアントであり、 DocumentAnalysisAsyncClient 非同期サービス クライアントです。 このドキュメントに示す例では、認証に DefaultAzureCredential という名前の資格情報オブジェクトを使用します。これは、ローカルの開発環境や運用環境を含むほとんどのシナリオに適しています。 さらに、運用環境での認証に マネージド ID を 使用することをお勧めします。 認証のさまざまな方法とそれに対応する資格情報の種類の詳細については、 Azure ID のドキュメントを参照してください。
サンプル: DefaultAzureCredential を使用して DocumentAnalysisAsyncClient を構築する
次のコード サンプルは、'DefaultAzureCredentialBuilder' を使用して を構成する の作成 DocumentAnalysisClientを示しています。
DocumentAnalysisClient documentAnalysisClient = new DocumentAnalysisClientBuilder()
.endpoint("{endpoint}")
.credential(new DefaultAzureCredentialBuilder().build())
.buildClient();
さらに、クライアントの作成に使用する次のコード サンプルを参照 AzureKeyCredential してください。
DocumentAnalysisClient documentAnalysisClient = new DocumentAnalysisClientBuilder()
.credential(new AzureKeyCredential("{key}"))
.endpoint("{endpoint}")
.buildClient();
メソッドの概要
メソッドの継承元: java.lang.Object
メソッドの詳細
beginAnalyzeDocument
public SyncPoller
事前構築済みモデルまたはカスタム構築済み分析モデルのいずれかを使用して、光学式文字認識 (OCR) を使用してドキュメントのデータを分析します。
このサービスは、実行時間の長い操作の取り消しをサポートせず、取り消しサポートがないことを示すエラー メッセージを返します。
Code sample
File document = new File("{local/file_path/fileName.jpg}");
String modelId = "{custom_trained_model_id}";
byte[] fileContent = Files.readAllBytes(document.toPath());
documentAnalysisClient.beginAnalyzeDocument(modelId, BinaryData.fromBytes(fileContent))
.getFinalResult()
.getDocuments().stream()
.map(AnalyzedDocument::getFields)
.forEach(documentFieldMap -> documentFieldMap.forEach((key, documentField) -> {
System.out.printf("Field text: %s%n", key);
System.out.printf("Field value data content: %s%n", documentField.getContent());
System.out.printf("Confidence score: %.2f%n", documentField.getConfidence());
}));
}
Parameters:
Returns:
beginAnalyzeDocument
public SyncPoller
事前構築済みのモデルまたはカスタム構築された分析モデルのいずれかを使用して、特定のドキュメントの光学式文字認識 (OCR) とセマンティック値を使用してドキュメントのデータを分析します。
このサービスは、実行時間の長い操作の取り消しをサポートせず、取り消しサポートがないことを示すエラー メッセージを返します。
Code sample
構成可能なオプションを使用してドキュメントを分析します。
File document = new File("{local/file_path/fileName.jpg}");
String modelId = "{custom_trained_model_id}";
byte[] fileContent = Files.readAllBytes(document.toPath());
documentAnalysisClient.beginAnalyzeDocument(modelId, BinaryData.fromBytes(fileContent),
new AnalyzeDocumentOptions().setPages(Arrays.asList("1", "3")), Context.NONE)
.getFinalResult()
.getDocuments().stream()
.map(AnalyzedDocument::getFields)
.forEach(documentFieldMap -> documentFieldMap.forEach((key, documentField) -> {
System.out.printf("Field text: %s%n", key);
System.out.printf("Field value data content: %s%n", documentField.getContent());
System.out.printf("Confidence score: %.2f%n", documentField.getConfidence());
}));
Parameters:
Returns:
beginAnalyzeDocumentFromUrl
public SyncPoller
事前構築済みのモデルまたはカスタム構築された分析モデルのいずれかを使用して、特定のドキュメントの光学式文字認識 (OCR) とセマンティック値を使用してドキュメントのデータを分析します。
サービスは実行時間の長い操作の取り消しをサポートせず、取り消しサポートがないことを示すエラー メッセージを返します
Code sample
ドキュメントの URL を使用してドキュメントを分析します。
String documentUrl = "{document_url}";
String modelId = "{custom_trained_model_id}";
documentAnalysisClient.beginAnalyzeDocumentFromUrl(modelId, documentUrl).getFinalResult()
.getDocuments().stream()
.map(AnalyzedDocument::getFields)
.forEach(documentFieldMap -> documentFieldMap.forEach((key, documentField) -> {
System.out.printf("Field text: %s%n", key);
System.out.printf("Field value data content: %s%n", documentField.getContent());
System.out.printf("Confidence score: %.2f%n", documentField.getConfidence());
}));
Parameters:
Returns:
beginAnalyzeDocumentFromUrl
public SyncPoller
事前構築済みのモデルまたはカスタム構築された分析モデルのいずれかを使用して、特定のドキュメントの光学式文字認識 (OCR) とセマンティック値を使用してドキュメントのデータを分析します。
サービスは実行時間の長い操作の取り消しをサポートせず、取り消しサポートがないことを示すエラー メッセージを返します
Code sample
構成可能なオプションを使用して、ドキュメントの URL を使用してドキュメントを分析します。
String documentUrl = "{document_url}";
String modelId = "{custom_trained_model_id}";
documentAnalysisClient.beginAnalyzeDocumentFromUrl(modelId, documentUrl).getFinalResult()
.getDocuments().stream()
.map(AnalyzedDocument::getFields)
.forEach(documentFieldMap -> documentFieldMap.forEach((key, documentField) -> {
System.out.printf("Field text: %s%n", key);
System.out.printf("Field value data content: %s%n", documentField.getContent());
System.out.printf("Confidence score: %.2f%n", documentField.getConfidence());
}));
Parameters:
Returns:
beginClassifyDocument
public SyncPoller
ドキュメント分類子を使用して、特定のドキュメントを分類します。 カスタム分類子モデルを構築する方法の詳細については、次を参照してください。
このサービスは、実行時間の長い操作の取り消しをサポートせず、取り消しサポートがないことを示すエラー メッセージを返します。
Code sample
File document = new File("{local/file_path/fileName.jpg}");
String classifierId = "{custom_trained_classifier_id}";
byte[] fileContent = Files.readAllBytes(document.toPath());
documentAnalysisClient.beginClassifyDocument(classifierId, BinaryData.fromBytes(fileContent))
.getFinalResult()
.getDocuments()
.forEach(analyzedDocument -> System.out.printf("Doc Type: %s%n", analyzedDocument.getDocType()));
Parameters:
Returns:
beginClassifyDocument
public SyncPoller
ドキュメント分類子を使用して、特定のドキュメントを分類します。 カスタム分類子モデルを構築する方法の詳細については、次を参照してください。
このサービスは、実行時間の長い操作の取り消しをサポートせず、取り消しサポートがないことを示すエラー メッセージを返します。
Code sample
File document = new File("{local/file_path/fileName.jpg}");
String classifierId = "{custom_trained_classifier_id}";
byte[] fileContent = Files.readAllBytes(document.toPath());
documentAnalysisClient.beginClassifyDocument(classifierId, BinaryData.fromBytes(fileContent), Context.NONE)
.getFinalResult()
.getDocuments()
.forEach(analyzedDocument -> System.out.printf("Doc Type: %s%n", analyzedDocument.getDocType()));
Parameters:
Returns:
beginClassifyDocumentFromUrl
public SyncPoller
ドキュメント分類子を使用して、特定のドキュメントを分類します。 カスタム分類子モデルを構築する方法の詳細については、次を参照してください。
サービスは実行時間の長い操作の取り消しをサポートせず、取り消しサポートがないことを示すエラー メッセージを返します
Code sample
構成可能なオプションを使用して、ドキュメントの URL を使用してドキュメントを分析します。
String documentUrl = "{file_source_url}";
String classifierId = "{custom_trained_classifier_id}";
documentAnalysisClient.beginClassifyDocumentFromUrl(classifierId, documentUrl)
.getFinalResult()
.getDocuments()
.forEach(analyzedDocument -> System.out.printf("Doc Type: %s%n", analyzedDocument.getDocType()));
Parameters:
Returns:
beginClassifyDocumentFromUrl
public SyncPoller
ドキュメント分類子を使用して、特定のドキュメントを分類します。 カスタム分類子モデルを構築する方法の詳細については、次を参照してください。
サービスは実行時間の長い操作の取り消しをサポートせず、取り消しサポートがないことを示すエラー メッセージを返します
Code sample
構成可能なオプションを使用して、ドキュメントの URL を使用してドキュメントを分析します。
String documentUrl = "{file_source_url}";
String classifierId = "{custom_trained_classifier_id}";
documentAnalysisClient.beginClassifyDocumentFromUrl(classifierId, documentUrl, Context.NONE)
.getFinalResult()
.getDocuments()
.forEach(analyzedDocument -> System.out.printf("Doc Type: %s%n", analyzedDocument.getDocType()));
Parameters:
Returns:
適用対象
Azure SDK for Java