你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
DocumentModelAdministrationClient 类
- java.
lang. Object - com.
azure. ai. formrecognizer. documentanalysis. administration. DocumentModelAdministrationClient
- com.
public final class DocumentModelAdministrationClient
此类提供异步客户端,用于连接到 Azure 认知服务表单识别器。
此客户端提供异步方法来执行:
- 生成自定义模型:使用 beginBuidlDocumentModel 方法生成自定义模型,从特定文档中提取数据,以便向 Azure 存储 Blob 容器提供容器 SAS URL。
- 组合自定义模型:使用 beginComposeDocumentModel 方法从现有模型集合的文档类型创建新模型。
- 复制自定义模型:使用 beginCopyDocumentModelTo 方法将自定义表单识别器模型复制到目标表单识别器资源。
- 自定义模型管理:分别使用 和 方法getDocumentModel(String modelId)listDocumentModels()deleteDocumentModel(String modelId)获取详细信息、删除和列出自定义模型。
- 操作管理:分别使用 getOperation(String operationId) 方法和获取有关 表单识别器 帐户的详细信息和listOperations()列出操作。
- 轮询和回调:它包括轮询服务以检查分析操作的状态或注册回调以在分析完成时接收通知的机制。
注意: 此客户端仅支持 V2022_08_31 和 更新。 使用较旧服务版本 FormRecognizerClient 和 .formrecognizer.training.FormTrainingClient。
服务客户端是开发人员使用 Azure 表单识别器的交互点。 DocumentModelAdministrationClient 是同步服务客户端, DocumentModelAdministrationAsyncClient 是异步服务客户端。 本文档中显示的示例使用名为 DefaultAzureCredential 的凭据对象进行身份验证,该对象适用于大多数方案,包括本地开发和生产环境。 此外,建议在生产环境中使用 托管标识 进行身份验证。 可以在 Azure 标识文档中找到有关不同身份验证方式及其相应凭据类型的详细信息。
示例:使用 DefaultAzureCredential 构造DocumentModelAdministrationAsyncClient
下面的代码示例演示如何使用“DefaultAzureCredentialBuilder”创建 DocumentModelAdministrationAsyncClient它来配置它。
DocumentModelAdministrationClient client = new DocumentModelAdministrationClientBuilder()
.endpoint("{endpoint}")
.credential(new DefaultAzureCredentialBuilder().build())
.buildClient();
此外,请参阅下面的代码示例以用于 AzureKeyCredential 创建客户端。
DocumentModelAdministrationAsyncClient documentModelAdministrationAsyncClient =
new DocumentModelAdministrationClientBuilder()
.credential(new AzureKeyCredential("{key}"))
.endpoint("{endpoint}")
.buildAsyncClient();
方法摘要
方法继承自 java.lang.Object
方法详细信息
beginBuildDocumentClassifier
public SyncPoller
生成自定义分类器文档模型。
分类器模型可以识别多个文档或单个文档的多个实例。 为此,每个类和两类文档至少需要五个文档。
该服务不支持取消长时间运行的操作,并返回一条错误消息,指示没有取消支持。
代码示例
String blobContainerUrl1040D = "{SAS_URL_of_your_container_in_blob_storage}";
String blobContainerUrl1040A = "{SAS_URL_of_your_container_in_blob_storage}";
HashMap<String, ClassifierDocumentTypeDetails> documentTypes = new HashMap<>();
documentTypes.put("1040-D", new ClassifierDocumentTypeDetails(new BlobContentSource(blobContainerUrl1040D)
));
documentTypes.put("1040-A", new ClassifierDocumentTypeDetails(new BlobContentSource(blobContainerUrl1040A)
));
DocumentClassifierDetails classifierDetails
= documentModelAdministrationClient.beginBuildDocumentClassifier(documentTypes)
.getFinalResult();
System.out.printf("Classifier ID: %s%n", classifierDetails.getClassifierId());
System.out.printf("Classifier description: %s%n", classifierDetails.getDescription());
System.out.printf("Classifier created on: %s%n", classifierDetails.getCreatedOn());
System.out.printf("Classifier expires on: %s%n", classifierDetails.getExpiresOn());
classifierDetails.getDocumentTypes().forEach((key, documentTypeDetails) -> {
if (documentTypeDetails.getContentSource() instanceof BlobContentSource) {
System.out.printf("Blob Source container Url: %s", ((BlobContentSource) documentTypeDetails
.getContentSource()).getContainerUrl());
}
});
Parameters:
Returns:
beginBuildDocumentClassifier
public SyncPoller
生成自定义分类器文档模型。
分类器模型可以识别多个文档或单个文档的多个实例。 为此,每个类和两类文档至少需要五个文档。
该服务不支持取消长时间运行的操作,并返回一条错误消息,指示没有取消支持。
代码示例
String blobContainerUrl1040D = "{SAS_URL_of_your_container_in_blob_storage}";
String blobContainerUrl1040A = "{SAS_URL_of_your_container_in_blob_storage}";
HashMap<String, ClassifierDocumentTypeDetails> documentTypesDetailsMap = new HashMap<>();
documentTypesDetailsMap.put("1040-D", new ClassifierDocumentTypeDetails(new BlobContentSource(blobContainerUrl1040D)
));
documentTypesDetailsMap.put("1040-A", new ClassifierDocumentTypeDetails(new BlobContentSource(blobContainerUrl1040A)
));
DocumentClassifierDetails classifierDetails
= documentModelAdministrationClient.beginBuildDocumentClassifier(documentTypesDetailsMap,
new BuildDocumentClassifierOptions()
.setClassifierId("classifierId")
.setDescription("classifier desc"),
Context.NONE)
.getFinalResult();
System.out.printf("Classifier ID: %s%n", classifierDetails.getClassifierId());
System.out.printf("Classifier description: %s%n", classifierDetails.getDescription());
System.out.printf("Classifier created on: %s%n", classifierDetails.getCreatedOn());
System.out.printf("Classifier expires on: %s%n", classifierDetails.getExpiresOn());
classifierDetails.getDocumentTypes().forEach((key, documentTypeDetails) -> {
if (documentTypeDetails.getContentSource() instanceof BlobContentSource) {
System.out.printf("Blob Source container Url: %s", ((BlobContentSource) documentTypeDetails
.getContentSource()).getContainerUrl());
}
});
Parameters:
Returns:
beginBuildDocumentModel
public SyncPoller
生成自定义文档分析模型。
模型是使用以下内容类型的文档构建的:“application/pdf”、“image/jpeg”、“image/png”、“image/tiff”、“image/bmp”。 忽略其他类型的内容。
该服务不支持取消长时间运行的操作,并返回一条错误消息,指示没有取消支持。
代码示例
String blobContainerUrl = "{SAS-URL-of-your-container-in-blob-storage}";
String fileList = "";
DocumentModelDetails documentModelDetails
= documentModelAdministrationClient.beginBuildDocumentModel(
new BlobFileListContentSource(blobContainerUrl, fileList),
DocumentModelBuildMode.TEMPLATE)
.getFinalResult();
System.out.printf("Model ID: %s%n", documentModelDetails.getModelId());
System.out.printf("Model Created on: %s%n", documentModelDetails.getCreatedOn());
documentModelDetails.getDocumentTypes().forEach((key, documentTypeDetails) -> {
documentTypeDetails.getFieldSchema().forEach((field, documentFieldSchema) -> {
System.out.printf("Field: %s", field);
System.out.printf("Field type: %s", documentFieldSchema.getType());
System.out.printf("Field confidence: %.2f", documentTypeDetails.getFieldConfidence().get(field));
});
});
Parameters:
Returns:
beginBuildDocumentModel
public SyncPoller
生成自定义文档分析模型。
模型是使用以下内容类型的文档构建的:“application/pdf”、“image/jpeg”、“image/png”、“image/tiff”、“image/bmp”。 忽略其他类型的内容。
该服务不支持取消长时间运行的操作,并返回一条错误消息,指示没有取消支持。
代码示例
String blobContainerUrl = "{SAS-URL-of-your-container-in-blob-storage}";
String fileList = "";
String modelId = "custom-model-id";
Map<String, String> attrs = new HashMap<String, String>();
attrs.put("createdBy", "sample");
DocumentModelDetails documentModelDetails
= documentModelAdministrationClient.beginBuildDocumentModel(
new BlobFileListContentSource(blobContainerUrl, fileList),
DocumentModelBuildMode.TEMPLATE,
new BuildDocumentModelOptions()
.setModelId(modelId)
.setDescription("model desc")
.setTags(attrs),
Context.NONE)
.getFinalResult();
System.out.printf("Model ID: %s%n", documentModelDetails.getModelId());
System.out.printf("Model Description: %s%n", documentModelDetails.getDescription());
System.out.printf("Model Created on: %s%n", documentModelDetails.getCreatedOn());
System.out.printf("Model assigned tags: %s%n", documentModelDetails.getTags());
documentModelDetails.getDocumentTypes().forEach((key, documentTypeDetails) -> {
documentTypeDetails.getFieldSchema().forEach((field, documentFieldSchema) -> {
System.out.printf("Field: %s", field);
System.out.printf("Field type: %s", documentFieldSchema.getType());
System.out.printf("Field confidence: %.2f", documentTypeDetails.getFieldConfidence().get(field));
});
});
Parameters:
Returns:
beginBuildDocumentModel
public SyncPoller
生成自定义文档分析模型。
模型是使用以下内容类型的文档构建的:“application/pdf”、“image/jpeg”、“image/png”、“image/tiff”、“image/bmp”。 忽略其他类型的内容。
该服务不支持取消长时间运行的操作,并返回一条错误消息,指示没有取消支持。
代码示例
String blobContainerUrl = "{SAS-URL-of-your-container-in-blob-storage}";
DocumentModelDetails documentModelDetails
= documentModelAdministrationClient.beginBuildDocumentModel(blobContainerUrl,
DocumentModelBuildMode.TEMPLATE)
.getFinalResult();
System.out.printf("Model ID: %s%n", documentModelDetails.getModelId());
System.out.printf("Model Created on: %s%n", documentModelDetails.getCreatedOn());
documentModelDetails.getDocumentTypes().forEach((key, documentTypeDetails) -> {
documentTypeDetails.getFieldSchema().forEach((field, documentFieldSchema) -> {
System.out.printf("Field: %s", field);
System.out.printf("Field type: %s", documentFieldSchema.getType());
System.out.printf("Field confidence: %.2f", documentTypeDetails.getFieldConfidence().get(field));
});
});
Parameters:
Returns:
beginBuildDocumentModel
public SyncPoller
生成自定义文档分析模型。
模型是使用以下内容类型的文档构建的:“application/pdf”、“image/jpeg”、“image/png”、“image/tiff”、“image/bmp”。 忽略其他类型的内容。
该服务不支持取消长时间运行的操作,并返回一条错误消息,指示没有取消支持。
代码示例
String blobContainerUrl = "{SAS-URL-of-your-container-in-blob-storage}";
String modelId = "custom-model-id";
String prefix = "Invoice";
Map<String, String> attrs = new HashMap<String, String>();
attrs.put("createdBy", "sample");
DocumentModelDetails documentModelDetails
= documentModelAdministrationClient.beginBuildDocumentModel(blobContainerUrl,
DocumentModelBuildMode.TEMPLATE,
prefix,
new BuildDocumentModelOptions()
.setModelId(modelId)
.setDescription("model desc")
.setTags(attrs),
Context.NONE)
.getFinalResult();
System.out.printf("Model ID: %s%n", documentModelDetails.getModelId());
System.out.printf("Model Description: %s%n", documentModelDetails.getDescription());
System.out.printf("Model Created on: %s%n", documentModelDetails.getCreatedOn());
System.out.printf("Model assigned tags: %s%n", documentModelDetails.getTags());
documentModelDetails.getDocumentTypes().forEach((key, documentTypeDetails) -> {
documentTypeDetails.getFieldSchema().forEach((field, documentFieldSchema) -> {
System.out.printf("Field: %s", field);
System.out.printf("Field type: %s", documentFieldSchema.getType());
System.out.printf("Field confidence: %.2f", documentTypeDetails.getFieldConfidence().get(field));
});
});
Parameters:
Returns:
beginComposeDocumentModel
public SyncPoller
从帐户中提供的现有模型列表创建组合模型。
如果列表包含无效的、不存在的模型 ID 或重复的 ID,则此操作将失败。
该服务不支持取消长时间运行的操作,并返回一条错误消息,指示没有取消支持。
代码示例
String modelId1 = "{custom-model-id_1}";
String modelId2 = "{custom-model-id_2}";
final DocumentModelDetails documentModelDetails
= documentModelAdministrationClient.beginComposeDocumentModel(Arrays.asList(modelId1, modelId2))
.getFinalResult();
System.out.printf("Model ID: %s%n", documentModelDetails.getModelId());
System.out.printf("Model Description: %s%n", documentModelDetails.getDescription());
System.out.printf("Model Created on: %s%n", documentModelDetails.getCreatedOn());
documentModelDetails.getDocumentTypes().forEach((key, documentTypeDetails) -> {
documentTypeDetails.getFieldSchema().forEach((field, documentFieldSchema) -> {
System.out.printf("Field: %s", field);
System.out.printf("Field type: %s", documentFieldSchema.getType());
System.out.printf("Field confidence: %.2f", documentTypeDetails.getFieldConfidence().get(field));
});
});
Parameters:
Returns:
beginComposeDocumentModel
public SyncPoller
从帐户中提供的现有模型列表创建组合模型。
如果列表包含无效的、不存在的模型 ID 或重复的 ID,则此操作将失败。
该服务不支持取消长时间运行的操作,并返回一条错误消息,指示没有取消支持。
代码示例
String modelId1 = "{custom-model-id_1}";
String modelId2 = "{custom-model-id_2}";
String modelId = "my-composed-model";
Map<String, String> attrs = new HashMap<String, String>();
attrs.put("createdBy", "sample");
final DocumentModelDetails documentModelDetails =
documentModelAdministrationClient.beginComposeDocumentModel(Arrays.asList(modelId1, modelId2),
new ComposeDocumentModelOptions()
.setModelId(modelId)
.setDescription("my composed model desc")
.setTags(attrs),
Context.NONE)
.setPollInterval(Duration.ofSeconds(5))
.getFinalResult();
System.out.printf("Model ID: %s%n", documentModelDetails.getModelId());
System.out.printf("Model Description: %s%n", documentModelDetails.getDescription());
System.out.printf("Model Created on: %s%n", documentModelDetails.getCreatedOn());
System.out.printf("Model assigned tags: %s%n", documentModelDetails.getTags());
documentModelDetails.getDocumentTypes().forEach((key, documentTypeDetails) -> {
documentTypeDetails.getFieldSchema().forEach((field, documentFieldSchema) -> {
System.out.printf("Field: %s", field);
System.out.printf("Field type: %s", documentFieldSchema.getType());
System.out.printf("Field confidence: %.2f", documentTypeDetails.getFieldConfidence().get(field));
});
});
Parameters:
Returns:
beginCopyDocumentModelTo
public SyncPoller
将源) (存储在此资源中的自定义模型复制到用户指定的目标表单识别器资源。
应将源表单识别器资源 (调用,该模型旨在) 复制。 目标参数应从目标资源的输出方法 getCopyAuthorization() 中提供。
该服务不支持取消长时间运行的操作,并返回一条错误消息,指示没有取消支持。
代码示例
String copyModelId = "copy-model";
// Get authorization to copy the model to target resource
DocumentModelCopyAuthorization documentModelCopyAuthorization
= documentModelAdministrationClient.getCopyAuthorization();
// Start copy operation from the source client
DocumentModelDetails documentModelDetails
= documentModelAdministrationClient.beginCopyDocumentModelTo(copyModelId, documentModelCopyAuthorization)
.getFinalResult();
System.out.printf("Copied model has model ID: %s, was created on: %s.%n,",
documentModelDetails.getModelId(),
documentModelDetails.getCreatedOn());
Parameters:
Returns:
beginCopyDocumentModelTo
public SyncPoller
将源) (存储在此资源中的自定义模型复制到用户指定的目标表单识别器资源。
应将源表单识别器资源 (调用,该模型旨在) 复制。 目标参数应从目标资源的输出方法 getCopyAuthorization() 中提供。
该服务不支持取消长时间运行的操作,并返回一条错误消息,指示没有取消支持。
代码示例
String copyModelId = "copy-model";
// Get authorization to copy the model to target resource
DocumentModelCopyAuthorization documentModelCopyAuthorization
= documentModelAdministrationClient.getCopyAuthorization();
// Start copy operation from the source client
DocumentModelDetails documentModelDetails =
documentModelAdministrationClient.beginCopyDocumentModelTo(copyModelId,
documentModelCopyAuthorization,
Context.NONE)
.getFinalResult();
System.out.printf("Copied model has model ID: %s, was created on: %s.%n,",
documentModelDetails.getModelId(),
documentModelDetails.getCreatedOn());
Parameters:
Returns:
deleteDocumentClassifier
public void deleteDocumentClassifier(String classifierId)
删除指定的文档分类器。
代码示例
String classifierId = "{classifierId}";
documentModelAdministrationClient.deleteDocumentClassifier(classifierId);
System.out.printf("Classifier ID: %s is deleted.%n", classifierId);
Parameters:
deleteDocumentClassifierWithResponse
public Response
删除指定的文档分类器。
代码示例
String classifierId = "{classifierId}";
Response<Void> response
= documentModelAdministrationClient.deleteDocumentClassifierWithResponse(classifierId, Context.NONE);
System.out.printf("Response Status Code: %d.", response.getStatusCode());
System.out.printf("Classifier ID: %s is deleted.%n", classifierId);
Parameters:
Returns:
deleteDocumentModel
public void deleteDocumentModel(String modelId)
删除指定的自定义文档分析模型。
代码示例
String modelId = "{custom-model-id}";
documentModelAdministrationClient.deleteDocumentModel(modelId);
System.out.printf("Model ID: %s is deleted.%n", modelId);
Parameters:
deleteDocumentModelWithResponse
public Response
删除指定的自定义文档分析模型。
代码示例
String modelId = "{custom-model-id}";
Response<Void> response
= documentModelAdministrationClient.deleteDocumentModelWithResponse(modelId, Context.NONE);
System.out.printf("Response Status Code: %d.", response.getStatusCode());
System.out.printf("Model ID: %s is deleted.%n", modelId);
Parameters:
Returns:
getCopyAuthorization
public DocumentModelCopyAuthorization getCopyAuthorization()
生成用于将自定义模型复制到目标表单识别器资源的授权。
这应由目标资源 (调用,其中模型将复制到) ,输出可以作为目标参数传递到 beginCopyDocumentModelTo(String sourceModelId, DocumentModelCopyAuthorization target)。
代码示例
DocumentModelCopyAuthorization documentModelCopyAuthorization
= documentModelAdministrationClient.getCopyAuthorization();
System.out.printf("Copy Authorization for model id: %s, access token: %s, expiration time: %s, "
+ "target resource ID; %s, target resource region: %s%n",
documentModelCopyAuthorization.getTargetModelId(),
documentModelCopyAuthorization.getAccessToken(),
documentModelCopyAuthorization.getExpiresOn(),
documentModelCopyAuthorization.getTargetResourceId(),
documentModelCopyAuthorization.getTargetResourceRegion()
);
Returns:
getCopyAuthorizationWithResponse
public Response
生成用于将自定义模型复制到目标表单识别器资源的授权。
这应由目标资源 (调用,其中模型将复制到) ,输出可以作为目标参数传递到 beginCopyDocumentModelTo(String sourceModelId, DocumentModelCopyAuthorization target)。
Parameters:
响应<DocumentModelCopyAuthorization> copyAuthorizationResponse = documentModelAdministrationClient.getCopyAuthorizationWithResponse ( new CopyAuthorizationOptions () .setModelId (modelId) .setDescription (“model-desc”) .setTags (attrs) , Context.NONE) ; System.out.printf("Copy Authorization operation returned with status: %s", copyAuthorizationResponse.getStatusCode()); DocumentModelCopyAuthorization documentModelCopyAuthorization = copyAuthorizationResponse.getValue(); System.out.printf("Copy Authorization for model id: %s, access token: %s, " + "expiration time: %s, target resource ID; %s, target resource region: %s%n", documentModelCopyAuthorization.getTargetModelId(), documentModelCopyAuthorization.getAccessToken(), documentModelCopyAuthorization.getExpiresOn(), documentModelCopyAuthorization.getTargetResourceId(), documentModelCopyAuthorization.getTargetResourceRegion() );
Returns:
getDocumentAnalysisClient
public DocumentAnalysisClient getDocumentAnalysisClient()
创建一个新的 DocumentAnalysisClient 对象。 新的 DocumentAnalysisClient 使用与 相同的请求策略管道 DocumentAnalysisClient。
Returns:
getDocumentClassifier
public DocumentClassifierDetails getDocumentClassifier(String classifierId)
按 ID 获取文档分类器的详细信息。
代码示例
String classifierId = "{classifierId}";
DocumentClassifierDetails documentClassifierDetails
= documentModelAdministrationClient.getDocumentClassifier(classifierId);
System.out.printf("Classifier ID: %s%n", documentClassifierDetails.getClassifierId());
System.out.printf("Classifier Description: %s%n", documentClassifierDetails.getDescription());
System.out.printf("Classifier Created on: %s%n", documentClassifierDetails.getCreatedOn());
documentClassifierDetails.getDocumentTypes().forEach((key, documentTypeDetails) -> {
if (documentTypeDetails.getContentSource() instanceof BlobContentSource) {
System.out.printf("Blob Source container Url: %s", ((BlobContentSource) documentTypeDetails
.getContentSource()).getContainerUrl());
}
if (documentTypeDetails.getContentSource() instanceof BlobFileListContentSource) {
System.out.printf("Blob File List Source container Url: %s",
((BlobFileListContentSource) documentTypeDetails
.getContentSource()).getContainerUrl());
}
});
Parameters:
Returns:
getDocumentClassifierWithResponse
public Response
按 ID 获取文档分类器的详细信息。
代码示例
String modelId = "{custom-model-id}";
Response<DocumentClassifierDetails> response
= documentModelAdministrationClient.getDocumentClassifierWithResponse(modelId, Context.NONE);
System.out.printf("Response Status Code: %d.", response.getStatusCode());
DocumentClassifierDetails documentClassifierDetails = response.getValue();
System.out.printf("Classifier ID: %s%n", documentClassifierDetails.getClassifierId());
System.out.printf("Classifier Description: %s%n", documentClassifierDetails.getDescription());
System.out.printf("Classifier Created on: %s%n", documentClassifierDetails.getCreatedOn());
documentClassifierDetails.getDocumentTypes().forEach((key, documentTypeDetails) -> {
if (documentTypeDetails.getContentSource() instanceof BlobContentSource) {
System.out.printf("Blob Source container Url: %s", ((BlobContentSource) documentTypeDetails
.getContentSource()).getContainerUrl());
}
if (documentTypeDetails.getContentSource() instanceof BlobFileListContentSource) {
System.out.printf("Blob File List Source container Url: %s",
((BlobFileListContentSource) documentTypeDetails
.getContentSource()).getContainerUrl());
}
});
Parameters:
Returns:
getDocumentModel
public DocumentModelDetails getDocumentModel(String modelId)
获取指定模型 ID 的详细信息。
代码示例
String modelId = "{custom-model-id}";
DocumentModelDetails documentModelDetails = documentModelAdministrationClient.getDocumentModel(modelId);
System.out.printf("Model ID: %s%n", documentModelDetails.getModelId());
System.out.printf("Model Description: %s%n", documentModelDetails.getDescription());
System.out.printf("Model Created on: %s%n", documentModelDetails.getCreatedOn());
documentModelDetails.getDocumentTypes().forEach((key, documentTypeDetails) -> {
documentTypeDetails.getFieldSchema().forEach((field, documentFieldSchema) -> {
System.out.printf("Field: %s", field);
System.out.printf("Field type: %s", documentFieldSchema.getType());
System.out.printf("Field confidence: %.2f", documentTypeDetails.getFieldConfidence().get(field));
});
});
Parameters:
Returns:
getDocumentModelWithResponse
public Response
获取指定模型 ID 的详细信息。
代码示例
String modelId = "{custom-model-id}";
Response<DocumentModelDetails> response
= documentModelAdministrationClient.getDocumentModelWithResponse(modelId, Context.NONE);
System.out.printf("Response Status Code: %d.", response.getStatusCode());
DocumentModelDetails documentModelDetails = response.getValue();
System.out.printf("Model ID: %s%n", documentModelDetails.getModelId());
System.out.printf("Model Description: %s%n", documentModelDetails.getDescription());
System.out.printf("Model Created on: %s%n", documentModelDetails.getCreatedOn());
documentModelDetails.getDocumentTypes().forEach((key, documentTypeDetails) -> {
documentTypeDetails.getFieldSchema().forEach((field, documentFieldSchema) -> {
System.out.printf("Field: %s", field);
System.out.printf("Field type: %s", documentFieldSchema.getType());
System.out.printf("Field confidence: %.2f", documentTypeDetails.getFieldConfidence().get(field));
});
});
Parameters:
Returns:
getOperation
public OperationDetails getOperation(String operationId)
使用 Http 响应获取指定 ID 的详细操作信息。
如果使用的操作 ID 超过 24 小时,则此操作将失败。
代码示例
String operationId = "{operation-id}";
OperationDetails operationDetails
= documentModelAdministrationClient.getOperation(operationId);
System.out.printf("Operation ID: %s%n", operationDetails.getOperationId());
System.out.printf("Operation Kind: %s%n", operationDetails.getKind());
System.out.printf("Operation Status: %s%n", operationDetails.getStatus());
System.out.printf("Model ID created with this operation: %s%n",
((DocumentModelBuildOperationDetails) operationDetails).getResult().getModelId());
if (OperationStatus.FAILED.equals(operationDetails.getStatus())) {
System.out.printf("Operation fail error: %s%n", operationDetails.getError().getMessage());
}
Parameters:
Returns:
getOperationWithResponse
public Response
使用 Http 响应获取指定 ID 的详细操作信息。
如果使用的操作 ID 超过 24 小时,则此操作将失败。
代码示例
String operationId = "{operation-id}";
Response<OperationDetails> response =
documentModelAdministrationClient.getOperationWithResponse(operationId, Context.NONE);
System.out.printf("Response Status Code: %d.", response.getStatusCode());
OperationDetails operationDetails = response.getValue();
System.out.printf("Operation ID: %s%n", operationDetails.getOperationId());
System.out.printf("Operation Kind: %s%n", operationDetails.getKind());
System.out.printf("Operation Status: %s%n", operationDetails.getStatus());
System.out.printf("Model ID created with this operation: %s%n",
((DocumentModelBuildOperationDetails) operationDetails).getResult().getModelId());
if (OperationStatus.FAILED.equals(operationDetails.getStatus())) {
System.out.printf("Operation fail error: %s%n", operationDetails.getError().getMessage());
}
Parameters:
Returns:
getResourceDetails
public ResourceDetails getResourceDetails()
获取有关当前表单识别器资源的信息。
代码示例
ResourceDetails resourceDetails = documentModelAdministrationClient.getResourceDetails();
System.out.printf("Max number of models that can be build for this account: %d%n",
resourceDetails.getCustomDocumentModelLimit());
System.out.printf("Current count of built document analysis models: %d%n",
resourceDetails.getCustomDocumentModelCount());
Returns:
getResourceDetailsWithResponse
public Response
使用 Http 响应和指定的 Context获取有关当前表单识别器资源的信息。
代码示例
Response<ResourceDetails> response =
documentModelAdministrationClient.getResourceDetailsWithResponse(Context.NONE);
System.out.printf("Response Status Code: %d.", response.getStatusCode());
ResourceDetails resourceDetails = response.getValue();
System.out.printf("Max number of models that can be build for this account: %d%n",
resourceDetails.getCustomDocumentModelLimit());
System.out.printf("Current count of built document analysis models: %d%n",
resourceDetails.getCustomDocumentModelCount());
Parameters:
Returns:
listDocumentClassifiers
public PagedIterable
列出已成功生成的 表单识别器 帐户上每个文档分类器的信息。
代码示例
documentModelAdministrationClient.listDocumentClassifiers()
.forEach(documentModel ->
System.out.printf("Classifier ID: %s, Classifier description: %s, Created on: %s.%n",
documentModel.getClassifierId(),
documentModel.getDescription(),
documentModel.getCreatedOn())
);
Returns:
listDocumentClassifiers
public PagedIterable
列出表单识别器帐户上使用 Http 响应和指定的 Context成功生成的每个文档分类器的信息。
代码示例
documentModelAdministrationClient.listDocumentClassifiers(Context.NONE)
.forEach(documentModel ->
System.out.printf("Classifier ID: %s, Classifier description: %s, Created on: %s.%n",
documentModel.getClassifierId(),
documentModel.getDescription(),
documentModel.getCreatedOn())
);
Parameters:
Returns:
listDocumentModels
public PagedIterable
列出已成功生成的表单识别器帐户上每个模型的信息。
代码示例
documentModelAdministrationClient.listDocumentModels()
.forEach(documentModel ->
System.out.printf("Model ID: %s, Model description: %s, Created on: %s.%n",
documentModel.getModelId(),
documentModel.getDescription(),
documentModel.getCreatedOn())
);
Returns:
listDocumentModels
public PagedIterable
列出表单识别器帐户上使用 Http 响应和指定的 Context成功生成的每个模型的信息。
代码示例
documentModelAdministrationClient.listDocumentModels(Context.NONE)
.forEach(documentModel ->
System.out.printf("Model ID: %s, Model description: %s, Created on: %s.%n",
documentModel.getModelId(),
documentModel.getDescription(),
documentModel.getCreatedOn())
);
Parameters:
Returns:
listOperations
public PagedIterable
列出过去 24 小时内表单识别器帐户上的每个模型操作的信息。
代码示例
PagedIterable<OperationSummary>
modelOperationInfo = documentModelAdministrationClient.listOperations();
modelOperationInfo.forEach(modelOperationSummary -> {
System.out.printf("Operation ID: %s%n", modelOperationSummary.getOperationId());
System.out.printf("Operation Status: %s%n", modelOperationSummary.getStatus());
System.out.printf("Operation Created on: %s%n", modelOperationSummary.getCreatedOn());
System.out.printf("Operation Percent completed: %d%n", modelOperationSummary.getPercentCompleted());
System.out.printf("Operation Kind: %s%n", modelOperationSummary.getKind());
System.out.printf("Operation Last updated on: %s%n", modelOperationSummary.getLastUpdatedOn());
System.out.printf("Operation resource location: %s%n", modelOperationSummary.getResourceLocation());
});
Returns:
listOperations
public PagedIterable
列出过去 24 小时内表单识别器帐户上每个操作的信息,其中包含 HTTP 响应和指定的 Context。
代码示例
PagedIterable<OperationSummary>
modelOperationInfo = documentModelAdministrationClient.listOperations(Context.NONE);
modelOperationInfo.forEach(modelOperationSummary -> {
System.out.printf("Operation ID: %s%n", modelOperationSummary.getOperationId());
System.out.printf("Operation Status: %s%n", modelOperationSummary.getStatus());
System.out.printf("Operation Created on: %s%n", modelOperationSummary.getCreatedOn());
System.out.printf("Operation Percent completed: %d%n", modelOperationSummary.getPercentCompleted());
System.out.printf("Operation Kind: %s%n", modelOperationSummary.getKind());
System.out.printf("Operation Last updated on: %s%n", modelOperationSummary.getLastUpdatedOn());
System.out.printf("Operation resource location: %s%n", modelOperationSummary.getResourceLocation());
});
Parameters:
Returns: