共用方式為


DocumentModelAdministrationClient class

用戶端,用於與表格辨識器服務的模型管理功能互動,例如建立、讀取、列出、刪除和複製模型。

範例:

Azure Active Directory

import { DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
import { DefaultAzureCredential } from "@azure/identity";

const endpoint = "https://<resource name>.cognitiveservices.azure.com";
const credential = new DefaultAzureCredential();

const client = new DocumentModelAdministrationClient(endpoint, credential);

API 金鑰 (訂用帳戶金鑰)

import { DocumentModelAdministrationClient, AzureKeyCredential } from "@azure/ai-form-recognizer";

const endpoint = "https://<resource name>.cognitiveservices.azure.com";
const credential = new AzureKeyCredential("<api key>");

const client = new DocumentModelAdministrationClient(endpoint, credential);

建構函式

DocumentModelAdministrationClient(string, KeyCredential, DocumentModelAdministrationClientOptions)

從資源端點和靜態 API 金鑰建立 DocumentModelAdministrationClient 實例 (KeyCredential) ,

範例:

import { DocumentModelAdministrationClient, AzureKeyCredential } from "@azure/ai-form-recognizer";

const endpoint = "https://<resource name>.cognitiveservices.azure.com";
const credential = new AzureKeyCredential("<api key>");

const client = new DocumentModelAdministrationClient(endpoint, credential);
DocumentModelAdministrationClient(string, TokenCredential, DocumentModelAdministrationClientOptions)

從資源端點和 Azure 身分識別 TokenCredential 建立 DocumentModelAdministrationClient 實例。

@azure/identity如需使用 Azure Active Directory 進行驗證的詳細資訊,請參閱套件。

範例:

import { DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
import { DefaultAzureCredential } from "@azure/identity";

const endpoint = "https://<resource name>.cognitiveservices.azure.com";
const credential = new DefaultAzureCredential();

const client = new DocumentModelAdministrationClient(endpoint, credential);

方法

beginBuildDocumentClassifier(string, DocumentClassifierDocumentTypeSources, BeginBuildDocumentClassifierOptions)

使用指定的分類器識別碼和檔案類型來建置新的檔分類器。

分類器識別碼在資源內的分類器之間必須是唯一的。

檔案類型會以物件的形式提供,將檔案類型的名稱對應至該檔案類型的訓練資料集。 支援兩種定型資料輸入法:

  • azureBlobSource,其會使用指定Azure Blob 儲存體容器中的資料來定型分類器。
  • azureBlobFileListSource,這類似于 azureBlobSource ,但允許使用 JSONL 格式的檔案清單,更精細地控制訓練資料集中包含的檔案。

表格辨識器服務會從 Azure 儲存體容器讀取訓練資料集,並指定為具有 SAS 權杖的容器 URL,讓服務後端能夠與容器通訊。 至少需要「讀取」和「清單」許可權。 此外,必須根據特定慣例來組織指定容器中的資料,此慣例記載于 服務的檔中,以建置自訂檔分類器

範例

const classifierId = "aNewClassifier";
const containerUrl1 = "<training data container SAS URL 1>";
const containerUrl2 = "<training data container SAS URL 2>";

const poller = await client.beginBuildDocumentClassifier(
  classifierId,
  {
    // The document types. Each entry in this object should map a document type name to a
    // `ClassifierDocumentTypeDetails` object
    "formX": {
      azureBlobSource: {
        containerUrl: containerUrl1,
      }
    },
    "formY": {
      azureBlobFileListSource: {
        containerUrl: containerUrl2,
        fileList: "path/to/fileList.jsonl"
      }
    },
  },
  {
    // Optionally, a text description may be attached to the classifier
    description: "This is an example classifier!"
  }
);

// Classifier building, like model creation operations, returns a poller that eventually produces a
// DocumentClassifierDetails object
const classifierDetails = await poller.pollUntilDone();

const {
  classifierId, // identical to the classifierId given when creating the classifier
  description, // identical to the description given when creating the classifier (if any)
  createdOn, // the Date (timestamp) that the classifier was created
  docTypes // information about the document types in the classifier and their details
} = classifierDetails;
beginBuildDocumentModel(string, DocumentModelSource, DocumentModelBuildMode, BeginBuildDocumentModelOptions)

從模型內容來源建立具有指定識別碼的新模型。

模型識別碼可以包含任何文字,只要其開頭不是「prebuilt-」 (,因為這些模型是指所有資源) 通用的預先建置表格辨識器模型,只要它不存在於資源內即可。

內容來源描述服務將用來讀取輸入定型資料的機制。 如需詳細資訊, <xref:DocumentModelContentSource> 請參閱類型。

範例

const modelId = "aNewModel";

const poller = await client.beginBuildDocumentModel(modelId, { containerUrl: "<SAS-encoded blob container URL>" }, {
  // Optionally, a text description may be attached to the model
  description: "This is an example model!"
});

// Model building, like all other model creation operations, returns a poller that eventually produces a ModelDetails
// object
const modelDetails = await poller.pollUntilDone();

const {
  modelId, // identical to the modelId given when creating the model
  description, // identical to the description given when creating the model
  createdOn, // the Date (timestamp) that the model was created
  docTypes // information about the document types in the model and their field schemas
} = modelDetails;
beginBuildDocumentModel(string, string, DocumentModelBuildMode, BeginBuildDocumentModelOptions)

從一組輸入檔和標記的欄位,建立具有指定識別碼的新模型。

模型識別碼可以包含任何文字,只要其開頭不是「prebuilt-」 (,因為這些模型是指所有資源) 通用的預先建置表格辨識器模型,只要它不存在於資源內即可。

表格辨識器服務會從 Azure 儲存體容器讀取訓練資料集,並指定為具有 SAS 權杖的容器 URL,讓服務後端能夠與容器通訊。 至少需要「讀取」和「清單」許可權。 此外,必須根據特定慣例來組織指定容器中的資料,此慣例記載于 用於建置自訂模型的服務檔中

範例

const modelId = "aNewModel";
const containerUrl = "<training data container SAS URL>";

const poller = await client.beginBuildDocumentModel(modelId, containerUrl, {
  // Optionally, a text description may be attached to the model
  description: "This is an example model!"
});

// Model building, like all other model creation operations, returns a poller that eventually produces a ModelDetails
// object
const modelDetails = await poller.pollUntilDone();

const {
  modelId, // identical to the modelId given when creating the model
  description, // identical to the description given when creating the model
  createdOn, // the Date (timestamp) that the model was created
  docTypes // information about the document types in the model and their field schemas
} = modelDetails;
beginComposeDocumentModel(string, Iterable<string>, BeginComposeDocumentModelOptions)

從數個預先存在的子模型建立單一組成模型。

產生的組成模型會結合其元件模型的檔案類型,並將分類步驟插入擷取管線中,以判斷其元件子模型最適合指定的輸入。

範例

const modelId = "aNewComposedModel";
const subModelIds = [
  "documentType1Model",
  "documentType2Model",
  "documentType3Model"
];

// The resulting composed model can classify and extract data from documents
// conforming to any of the above document types
const poller = await client.beginComposeDocumentModel(modelId, subModelIds, {
  description: "This is a composed model that can handle several document types."
});

// Model composition, like all other model creation operations, returns a poller that eventually produces a
// ModelDetails object
const modelDetails = await poller.pollUntilDone();

const {
  modelId, // identical to the modelId given when creating the model
  description, // identical to the description given when creating the model
  createdOn, // the Date (timestamp) that the model was created
  docTypes // information about the document types of the composed submodels
} = modelDetails;
beginCopyModelTo(string, CopyAuthorization, BeginCopyModelOptions)

將具有指定識別碼的模型複製到由指定複製授權編碼的資源和模型識別碼。

請參閱 CopyAuthorizationgetCopyAuthorization

範例

// We need a client for the source model's resource
const sourceEndpoint = "https://<source resource name>.cognitiveservices.azure.com";
const sourceCredential = new AzureKeyCredential("<source api key>");
const sourceClient = new DocumentModelAdministrationClient(sourceEndpoint, sourceCredential);

// We create the copy authorization using a client authenticated with the destination resource. Note that these two
// resources can be the same (you can copy a model to a new ID in the same resource).
const copyAuthorization = await client.getCopyAuthorization("<destination model ID>");

// Finally, use the _source_ client to copy the model and await the copy operation
const poller = await sourceClient.beginCopyModelTo("<source model ID>");

// Model copying, like all other model creation operations, returns a poller that eventually produces a ModelDetails
// object
const modelDetails = await poller.pollUntilDone();

const {
  modelId, // identical to the modelId given when creating the copy authorization
  description, // identical to the description given when creating the copy authorization
  createdOn, // the Date (timestamp) that the model was created
  docTypes // information about the document types of the model (identical to the original, source model)
} = modelDetails;
deleteDocumentClassifier(string, OperationOptions)

如果存在,則會從用戶端資源中刪除具有指定識別碼的分類器。 無法還原此作業。

範例

await client.deleteDocumentClassifier("<classifier ID to delete>"));
deleteDocumentModel(string, DeleteDocumentModelOptions)

如果模型存在,則會從用戶端的資源中刪除具有指定識別碼的模型。 無法還原此作業。

範例

await client.deleteDocumentModel("<model ID to delete>"));
getCopyAuthorization(string, GetCopyAuthorizationOptions)

建立授權,以將模型複製到與 方法搭配 beginCopyModelTo 使用的資源。

會將 CopyAuthorization 另一個認知服務資源授與在此用戶端資源中建立模型的許可權,此資源具有編碼為授權的模型識別碼和選擇性描述。

範例

// The copyAuthorization data structure stored below grants any cognitive services resource the right to copy a
// model into the client's resource with the given destination model ID.
const copyAuthorization = await client.getCopyAuthorization("<destination model ID>");
getDocumentClassifier(string, OperationOptions)

依識別碼擷取分類器 (DocumentClassifierDetails) 的相關資訊。

範例

const classifierId = "<classifier ID";

const {
  classifierId, // identical to the ID given when calling `getDocumentClassifier`
  description, // a textual description of the classifier, if provided during classifier creation
  createdOn, // the Date (timestamp) that the classifier was created
  // information about the document types in the classifier and their corresponding traning data
  docTypes
} = await client.getDocumentClassifier(classifierId);

// The `docTypes` property is a map of document type names to information about the training data
// for that document type.
for (const [docTypeName, classifierDocTypeDetails] of Object.entries(docTypes)) {
 console.log(`- '${docTypeName}': `, classifierDocTypeDetails);
}
getDocumentModel(string, GetModelOptions)

擷取依識別碼 (DocumentModelDetails) 模型的相關資訊。

這個方法可以擷取自訂和預先建置模型的相關資訊。

中斷性變更

在舊版的 表格辨識器 REST API 和 SDK 中 getModel ,方法可能會傳回任何模型,甚至是因為錯誤而無法建立的模型。 在新的服務版本中, getDocumentModel 而且 listDocumentModels只會 (成功建立的模型,也就是「已準備好」使用) 的模型。 失敗的模型現在會透過「作業」API 擷取,請參閱 getOperationlistOperations

範例

// The ID of the prebuilt business card model
const modelId = "prebuilt-businessCard";

const {
  modelId, // identical to the modelId given when calling `getDocumentModel`
  description, // a textual description of the model, if provided during model creation
  createdOn, // the Date (timestamp) that the model was created
  // information about the document types in the model and their field schemas
  docTypes: {
    // the document type of the prebuilt business card model
    "prebuilt:businesscard": {
      // an optional, textual description of this document type
      description,
      // the schema of the fields in this document type, see the FieldSchema type
      fieldSchema,
      // the service's confidences in the fields (an object with field names as properties and numeric confidence
      // values)
      fieldConfidence
    }
  }
} = await client.getDocumentModel(modelId);
getOperation(string, GetOperationOptions)

依識別碼擷 OperationDetails 取作業 () 的相關資訊。

作業代表非分析工作,例如建置、撰寫或複製模型。

getResourceDetails(GetResourceDetailsOptions)

擷取此用戶端資源的基本資訊。

範例

const {
  // Information about the custom models in the current resource
  customDocumentModelDetails: {
    // The number of custom models in the current resource
    count,
    // The maximum number of models that the current resource can support
    limit
  }
} = await client.getResourceDetails();
listDocumentClassifiers(ListModelsOptions)

列出資源中分類器的詳細資料。 此作業支援分頁。

範例

非同步反復專案

for await (const details of client.listDocumentClassifiers()) {
  const {
    classifierId, // The classifier's unique ID
    description, // a textual description of the classifier, if provided during creation
    docTypes, // information about the document types in the classifier and their corresponding traning data
  } = details;
}

依頁面

// The listDocumentClassifiers method is paged, and you can iterate by page using the `byPage` method.
const pages = client.listDocumentClassifiers().byPage();

for await (const page of pages) {
  // Each page is an array of classifiers and can be iterated synchronously
  for (const details of page) {
    const {
      classifierId, // The classifier's unique ID
      description, // a textual description of the classifier, if provided during creation
      docTypes, // information about the document types in the classifier and their corresponding traning data
    } = details;
  }
}
listDocumentModels(ListModelsOptions)

列出資源中的模型摘要。 將會包含自訂和預先建置的模型。 此作業支援分頁。

模型摘要 (DocumentModelSummary) 只包含模型的基本資訊,而且不包含模型中檔案類型的相關資訊 (,例如欄位架構和信賴值) 。

若要存取模型的完整資訊,請使用 getDocumentModel

中斷性變更

在舊版的 表格辨識器 REST API 和 SDK 中 listModels ,方法會傳回所有模型,即使是因為錯誤而無法建立的模型。 在新的服務版本中, listDocumentModels 而且 getDocumentModel只會 (成功建立的模型,也就是「已準備好」使用) 的模型。 失敗的模型現在會透過「作業」API 擷取,請參閱 getOperationlistOperations

範例

非同步反復專案

for await (const summary of client.listDocumentModels()) {
  const {
    modelId, // The model's unique ID
    description, // a textual description of the model, if provided during model creation
  } = summary;

  // You can get the full model info using `getDocumentModel`
  const model = await client.getDocumentModel(modelId);
}

依頁面

// The listDocumentModels method is paged, and you can iterate by page using the `byPage` method.
const pages = client.listDocumentModels().byPage();

for await (const page of pages) {
  // Each page is an array of models and can be iterated synchronously
  for (const model of page) {
    const {
      modelId, // The model's unique ID
      description, // a textual description of the model, if provided during model creation
    } = summary;

    // You can get the full model info using `getDocumentModel`
    const model = await client.getDocumentModel(modelId);
  }
}
listOperations(ListOperationsOptions)

列出資源中的模型建立作業。 這會產生所有作業,包括無法成功建立模型的作業。 此作業支援分頁。

範例

非同步反復專案

for await (const operation of client.listOperations()) {
  const {
    operationId, // the operation's GUID
    status, // the operation status, one of "notStarted", "running", "succeeded", "failed", or "canceled"
    percentCompleted // the progress of the operation, from 0 to 100
  } = operation;
}

依頁面

// The listOperations method is paged, and you can iterate by page using the `byPage` method.
const pages = client.listOperations().byPage();

for await (const page of pages) {
  // Each page is an array of operation info objects and can be iterated synchronously
  for (const operation of page) {
    const {
      operationId, // the operation's GUID
      status, // the operation status, one of "notStarted", "running", "succeeded", "failed", or "canceled"
      percentCompleted // the progress of the operation, from 0 to 100
    } = operation;
  }
}

建構函式詳細資料

DocumentModelAdministrationClient(string, KeyCredential, DocumentModelAdministrationClientOptions)

從資源端點和靜態 API 金鑰建立 DocumentModelAdministrationClient 實例 (KeyCredential) ,

範例:

import { DocumentModelAdministrationClient, AzureKeyCredential } from "@azure/ai-form-recognizer";

const endpoint = "https://<resource name>.cognitiveservices.azure.com";
const credential = new AzureKeyCredential("<api key>");

const client = new DocumentModelAdministrationClient(endpoint, credential);
new DocumentModelAdministrationClient(endpoint: string, credential: KeyCredential, options?: DocumentModelAdministrationClientOptions)

參數

endpoint

string

Azure 認知服務實例的端點 URL

credential
KeyCredential

包含認知服務實例訂用帳戶金鑰的 KeyCredential

options
DocumentModelAdministrationClientOptions

在用戶端中設定所有方法的選擇性設定

DocumentModelAdministrationClient(string, TokenCredential, DocumentModelAdministrationClientOptions)

從資源端點和 Azure 身分識別 TokenCredential 建立 DocumentModelAdministrationClient 實例。

@azure/identity如需使用 Azure Active Directory 進行驗證的詳細資訊,請參閱套件。

範例:

import { DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
import { DefaultAzureCredential } from "@azure/identity";

const endpoint = "https://<resource name>.cognitiveservices.azure.com";
const credential = new DefaultAzureCredential();

const client = new DocumentModelAdministrationClient(endpoint, credential);
new DocumentModelAdministrationClient(endpoint: string, credential: TokenCredential, options?: DocumentModelAdministrationClientOptions)

參數

endpoint

string

Azure 認知服務實例的端點 URL

credential
TokenCredential

來自封裝的 @azure/identity TokenCredential 實例

options
DocumentModelAdministrationClientOptions

在用戶端中設定所有方法的選擇性設定

方法詳細資料

beginBuildDocumentClassifier(string, DocumentClassifierDocumentTypeSources, BeginBuildDocumentClassifierOptions)

使用指定的分類器識別碼和檔案類型來建置新的檔分類器。

分類器識別碼在資源內的分類器之間必須是唯一的。

檔案類型會以物件的形式提供,將檔案類型的名稱對應至該檔案類型的訓練資料集。 支援兩種定型資料輸入法:

  • azureBlobSource,其會使用指定Azure Blob 儲存體容器中的資料來定型分類器。
  • azureBlobFileListSource,這類似于 azureBlobSource ,但允許使用 JSONL 格式的檔案清單,更精細地控制訓練資料集中包含的檔案。

表格辨識器服務會從 Azure 儲存體容器讀取訓練資料集,並指定為具有 SAS 權杖的容器 URL,讓服務後端能夠與容器通訊。 至少需要「讀取」和「清單」許可權。 此外,必須根據特定慣例來組織指定容器中的資料,此慣例記載于 服務的檔中,以建置自訂檔分類器

範例

const classifierId = "aNewClassifier";
const containerUrl1 = "<training data container SAS URL 1>";
const containerUrl2 = "<training data container SAS URL 2>";

const poller = await client.beginBuildDocumentClassifier(
  classifierId,
  {
    // The document types. Each entry in this object should map a document type name to a
    // `ClassifierDocumentTypeDetails` object
    "formX": {
      azureBlobSource: {
        containerUrl: containerUrl1,
      }
    },
    "formY": {
      azureBlobFileListSource: {
        containerUrl: containerUrl2,
        fileList: "path/to/fileList.jsonl"
      }
    },
  },
  {
    // Optionally, a text description may be attached to the classifier
    description: "This is an example classifier!"
  }
);

// Classifier building, like model creation operations, returns a poller that eventually produces a
// DocumentClassifierDetails object
const classifierDetails = await poller.pollUntilDone();

const {
  classifierId, // identical to the classifierId given when creating the classifier
  description, // identical to the description given when creating the classifier (if any)
  createdOn, // the Date (timestamp) that the classifier was created
  docTypes // information about the document types in the classifier and their details
} = classifierDetails;
function beginBuildDocumentClassifier(classifierId: string, docTypeSources: DocumentClassifierDocumentTypeSources, options?: BeginBuildDocumentClassifierOptions): Promise<DocumentClassifierPoller>

參數

classifierId

string

要建立之分類器的唯一識別碼

docTypeSources
DocumentClassifierDocumentTypeSources

要包含在分類器及其來源中的檔案類型, (檔案類型名稱對應至 ClassifierDocumentTypeDetails)

options
BeginBuildDocumentClassifierOptions

分類器建置作業的選擇性設定

傳回

長時間執行的作業 (輪詢器) ,最終會產生已建立的分類器詳細資料或錯誤

beginBuildDocumentModel(string, DocumentModelSource, DocumentModelBuildMode, BeginBuildDocumentModelOptions)

從模型內容來源建立具有指定識別碼的新模型。

模型識別碼可以包含任何文字,只要其開頭不是「prebuilt-」 (,因為這些模型是指所有資源) 通用的預先建置表格辨識器模型,只要它不存在於資源內即可。

內容來源描述服務將用來讀取輸入定型資料的機制。 如需詳細資訊, <xref:DocumentModelContentSource> 請參閱類型。

範例

const modelId = "aNewModel";

const poller = await client.beginBuildDocumentModel(modelId, { containerUrl: "<SAS-encoded blob container URL>" }, {
  // Optionally, a text description may be attached to the model
  description: "This is an example model!"
});

// Model building, like all other model creation operations, returns a poller that eventually produces a ModelDetails
// object
const modelDetails = await poller.pollUntilDone();

const {
  modelId, // identical to the modelId given when creating the model
  description, // identical to the description given when creating the model
  createdOn, // the Date (timestamp) that the model was created
  docTypes // information about the document types in the model and their field schemas
} = modelDetails;
function beginBuildDocumentModel(modelId: string, contentSource: DocumentModelSource, buildMode: DocumentModelBuildMode, options?: BeginBuildDocumentModelOptions): Promise<DocumentModelPoller>

參數

modelId

string

要建立之模型的唯一識別碼

contentSource
DocumentModelSource

提供此模型定型資料的內容來源

buildMode

DocumentModelBuildMode

建置模型時要使用的模式 (請參閱 DocumentModelBuildMode)

options
BeginBuildDocumentModelOptions

模型建置作業的選擇性設定

傳回

長時間執行的作業 (輪詢器) ,最終會產生已建立的模型資訊或錯誤

beginBuildDocumentModel(string, string, DocumentModelBuildMode, BeginBuildDocumentModelOptions)

從一組輸入檔和標記的欄位,建立具有指定識別碼的新模型。

模型識別碼可以包含任何文字,只要其開頭不是「prebuilt-」 (,因為這些模型是指所有資源) 通用的預先建置表格辨識器模型,只要它不存在於資源內即可。

表格辨識器服務會從 Azure 儲存體容器讀取訓練資料集,並指定為具有 SAS 權杖的容器 URL,讓服務後端能夠與容器通訊。 至少需要「讀取」和「清單」許可權。 此外,必須根據特定慣例來組織指定容器中的資料,此慣例記載于 用於建置自訂模型的服務檔中

範例

const modelId = "aNewModel";
const containerUrl = "<training data container SAS URL>";

const poller = await client.beginBuildDocumentModel(modelId, containerUrl, {
  // Optionally, a text description may be attached to the model
  description: "This is an example model!"
});

// Model building, like all other model creation operations, returns a poller that eventually produces a ModelDetails
// object
const modelDetails = await poller.pollUntilDone();

const {
  modelId, // identical to the modelId given when creating the model
  description, // identical to the description given when creating the model
  createdOn, // the Date (timestamp) that the model was created
  docTypes // information about the document types in the model and their field schemas
} = modelDetails;
function beginBuildDocumentModel(modelId: string, containerUrl: string, buildMode: DocumentModelBuildMode, options?: BeginBuildDocumentModelOptions): Promise<DocumentModelPoller>

參數

modelId

string

要建立之模型的唯一識別碼

containerUrl

string

保存訓練資料集的 Azure 儲存體容器 SAS 編碼 URL

buildMode

DocumentModelBuildMode

建置模型時要使用的模式 (請參閱 DocumentModelBuildMode)

options
BeginBuildDocumentModelOptions

模型建置作業的選擇性設定

傳回

長時間執行的作業 (輪詢器) ,最終會產生已建立的模型資訊或錯誤

beginComposeDocumentModel(string, Iterable<string>, BeginComposeDocumentModelOptions)

從數個預先存在的子模型建立單一組成模型。

產生的組成模型會結合其元件模型的檔案類型,並將分類步驟插入擷取管線中,以判斷其元件子模型最適合指定的輸入。

範例

const modelId = "aNewComposedModel";
const subModelIds = [
  "documentType1Model",
  "documentType2Model",
  "documentType3Model"
];

// The resulting composed model can classify and extract data from documents
// conforming to any of the above document types
const poller = await client.beginComposeDocumentModel(modelId, subModelIds, {
  description: "This is a composed model that can handle several document types."
});

// Model composition, like all other model creation operations, returns a poller that eventually produces a
// ModelDetails object
const modelDetails = await poller.pollUntilDone();

const {
  modelId, // identical to the modelId given when creating the model
  description, // identical to the description given when creating the model
  createdOn, // the Date (timestamp) that the model was created
  docTypes // information about the document types of the composed submodels
} = modelDetails;
function beginComposeDocumentModel(modelId: string, componentModelIds: Iterable<string>, options?: BeginComposeDocumentModelOptions): Promise<DocumentModelPoller>

參數

modelId

string

要建立之模型的唯一識別碼

componentModelIds

Iterable<string>

可反覆運算的字串,代表要撰寫之模型的唯一模型識別碼

options
BeginComposeDocumentModelOptions

建立模型的選擇性設定

傳回

長時間執行的作業 (輪詢器) ,最終會產生已建立的模型資訊或錯誤

beginCopyModelTo(string, CopyAuthorization, BeginCopyModelOptions)

將具有指定識別碼的模型複製到由指定複製授權編碼的資源和模型識別碼。

請參閱 CopyAuthorizationgetCopyAuthorization

範例

// We need a client for the source model's resource
const sourceEndpoint = "https://<source resource name>.cognitiveservices.azure.com";
const sourceCredential = new AzureKeyCredential("<source api key>");
const sourceClient = new DocumentModelAdministrationClient(sourceEndpoint, sourceCredential);

// We create the copy authorization using a client authenticated with the destination resource. Note that these two
// resources can be the same (you can copy a model to a new ID in the same resource).
const copyAuthorization = await client.getCopyAuthorization("<destination model ID>");

// Finally, use the _source_ client to copy the model and await the copy operation
const poller = await sourceClient.beginCopyModelTo("<source model ID>");

// Model copying, like all other model creation operations, returns a poller that eventually produces a ModelDetails
// object
const modelDetails = await poller.pollUntilDone();

const {
  modelId, // identical to the modelId given when creating the copy authorization
  description, // identical to the description given when creating the copy authorization
  createdOn, // the Date (timestamp) that the model was created
  docTypes // information about the document types of the model (identical to the original, source model)
} = modelDetails;
function beginCopyModelTo(sourceModelId: string, authorization: CopyAuthorization, options?: BeginCopyModelOptions): Promise<DocumentModelPoller>

參數

sourceModelId

string

將複製之來源模型的唯一識別碼

authorization
CopyAuthorization

使用getCopyAuthorization建立的複製模型的授權

options
BeginCopyModelOptions

的選擇性設定

傳回

長時間執行的作業 (輪詢器) ,最終會產生複製的模型資訊或錯誤

deleteDocumentClassifier(string, OperationOptions)

如果存在,則會從用戶端資源中刪除具有指定識別碼的分類器。 無法還原此作業。

範例

await client.deleteDocumentClassifier("<classifier ID to delete>"));
function deleteDocumentClassifier(classifierId: string, options?: OperationOptions): Promise<void>

參數

classifierId

string

要從資源中刪除之分類器的唯一識別碼

options
OperationOptions

要求的選擇性設定

傳回

Promise<void>

deleteDocumentModel(string, DeleteDocumentModelOptions)

如果模型存在,則會從用戶端的資源中刪除具有指定識別碼的模型。 無法還原此作業。

範例

await client.deleteDocumentModel("<model ID to delete>"));
function deleteDocumentModel(modelId: string, options?: DeleteDocumentModelOptions): Promise<void>

參數

modelId

string

要從資源中刪除之模型的唯一識別碼

options
DeleteDocumentModelOptions

要求的選擇性設定

傳回

Promise<void>

getCopyAuthorization(string, GetCopyAuthorizationOptions)

建立授權,以將模型複製到與 方法搭配 beginCopyModelTo 使用的資源。

會將 CopyAuthorization 另一個認知服務資源授與在此用戶端資源中建立模型的許可權,此資源具有編碼為授權的模型識別碼和選擇性描述。

範例

// The copyAuthorization data structure stored below grants any cognitive services resource the right to copy a
// model into the client's resource with the given destination model ID.
const copyAuthorization = await client.getCopyAuthorization("<destination model ID>");
function getCopyAuthorization(destinationModelId: string, options?: GetCopyAuthorizationOptions): Promise<CopyAuthorization>

參數

destinationModelId

string

目的地模型的唯一識別碼 (將模型複製到)

options
GetCopyAuthorizationOptions

用於建立複製授權的選擇性設定

傳回

將指定 modelId 和選擇性描述編碼的複製授權

getDocumentClassifier(string, OperationOptions)

依識別碼擷取分類器 (DocumentClassifierDetails) 的相關資訊。

範例

const classifierId = "<classifier ID";

const {
  classifierId, // identical to the ID given when calling `getDocumentClassifier`
  description, // a textual description of the classifier, if provided during classifier creation
  createdOn, // the Date (timestamp) that the classifier was created
  // information about the document types in the classifier and their corresponding traning data
  docTypes
} = await client.getDocumentClassifier(classifierId);

// The `docTypes` property is a map of document type names to information about the training data
// for that document type.
for (const [docTypeName, classifierDocTypeDetails] of Object.entries(docTypes)) {
 console.log(`- '${docTypeName}': `, classifierDocTypeDetails);
}
function getDocumentClassifier(classifierId: string, options?: OperationOptions): Promise<DocumentClassifierDetails>

參數

classifierId

string

要查詢之分類器的唯一識別碼

options
OperationOptions

要求的選擇性設定

傳回

具有指定識別碼之分類器的相關資訊

getDocumentModel(string, GetModelOptions)

擷取依識別碼 (DocumentModelDetails) 模型的相關資訊。

這個方法可以擷取自訂和預先建置模型的相關資訊。

中斷性變更

在舊版的 表格辨識器 REST API 和 SDK 中 getModel ,方法可能會傳回任何模型,甚至是因為錯誤而無法建立的模型。 在新的服務版本中, getDocumentModel 而且 listDocumentModels只會 (成功建立的模型,也就是「已準備好」使用) 的模型。 失敗的模型現在會透過「作業」API 擷取,請參閱 getOperationlistOperations

範例

// The ID of the prebuilt business card model
const modelId = "prebuilt-businessCard";

const {
  modelId, // identical to the modelId given when calling `getDocumentModel`
  description, // a textual description of the model, if provided during model creation
  createdOn, // the Date (timestamp) that the model was created
  // information about the document types in the model and their field schemas
  docTypes: {
    // the document type of the prebuilt business card model
    "prebuilt:businesscard": {
      // an optional, textual description of this document type
      description,
      // the schema of the fields in this document type, see the FieldSchema type
      fieldSchema,
      // the service's confidences in the fields (an object with field names as properties and numeric confidence
      // values)
      fieldConfidence
    }
  }
} = await client.getDocumentModel(modelId);
function getDocumentModel(modelId: string, options?: GetModelOptions): Promise<DocumentModelDetails>

參數

modelId

string

要查詢之模型的唯一識別碼

options
GetModelOptions

要求的選擇性設定

傳回

具有指定識別碼之模型的相關資訊

getOperation(string, GetOperationOptions)

依識別碼擷 OperationDetails 取作業 () 的相關資訊。

作業代表非分析工作,例如建置、撰寫或複製模型。

function getOperation(operationId: string, options?: GetOperationOptions): Promise<OperationDetails>

參數

operationId

string

要查詢之作業的識別碼

options
GetOperationOptions

要求的選擇性設定

傳回

Promise<OperationDetails>

具有指定識別碼之作業的相關資訊

範例

// The ID of the operation, which should be a GUID
const operationId = "<operation GUID>";

const {
  operationId, // identical to the operationId given when calling `getOperation`
  kind, // the operation kind, one of "documentModelBuild", "documentModelCompose", or "documentModelCopyTo"
  status, // the status of the operation, one of "notStarted", "running", "failed", "succeeded", or "canceled"
  percentCompleted, // a number between 0 and 100 representing the progress of the operation
  createdOn, // a Date object that reflects the time when the operation was started
  lastUpdatedOn, // a Date object that reflects the time when the operation state was last modified
} = await client.getOperation(operationId);

getResourceDetails(GetResourceDetailsOptions)

擷取此用戶端資源的基本資訊。

範例

const {
  // Information about the custom models in the current resource
  customDocumentModelDetails: {
    // The number of custom models in the current resource
    count,
    // The maximum number of models that the current resource can support
    limit
  }
} = await client.getResourceDetails();
function getResourceDetails(options?: GetResourceDetailsOptions): Promise<ResourceDetails>

參數

options
GetResourceDetailsOptions

要求的選擇性設定

傳回

Promise<ResourceDetails>

此用戶端資源的基本資訊

listDocumentClassifiers(ListModelsOptions)

列出資源中分類器的詳細資料。 此作業支援分頁。

範例

非同步反復專案

for await (const details of client.listDocumentClassifiers()) {
  const {
    classifierId, // The classifier's unique ID
    description, // a textual description of the classifier, if provided during creation
    docTypes, // information about the document types in the classifier and their corresponding traning data
  } = details;
}

依頁面

// The listDocumentClassifiers method is paged, and you can iterate by page using the `byPage` method.
const pages = client.listDocumentClassifiers().byPage();

for await (const page of pages) {
  // Each page is an array of classifiers and can be iterated synchronously
  for (const details of page) {
    const {
      classifierId, // The classifier's unique ID
      description, // a textual description of the classifier, if provided during creation
      docTypes, // information about the document types in the classifier and their corresponding traning data
    } = details;
  }
}
function listDocumentClassifiers(options?: ListModelsOptions): PagedAsyncIterableIterator<DocumentClassifierDetails, DocumentClassifierDetails[], PageSettings>

參數

options
ListModelsOptions

分類器要求的選擇性設定

傳回

可非同步反覆運算支援分頁的分類器詳細資料

listDocumentModels(ListModelsOptions)

列出資源中的模型摘要。 將會包含自訂和預先建置的模型。 此作業支援分頁。

模型摘要 (DocumentModelSummary) 只包含模型的基本資訊,而且不包含模型中檔案類型的相關資訊 (,例如欄位架構和信賴值) 。

若要存取模型的完整資訊,請使用 getDocumentModel

中斷性變更

在舊版的 表格辨識器 REST API 和 SDK 中 listModels ,方法會傳回所有模型,即使是因為錯誤而無法建立的模型。 在新的服務版本中, listDocumentModels 而且 getDocumentModel只會 (成功建立的模型,也就是「已準備好」使用) 的模型。 失敗的模型現在會透過「作業」API 擷取,請參閱 getOperationlistOperations

範例

非同步反復專案

for await (const summary of client.listDocumentModels()) {
  const {
    modelId, // The model's unique ID
    description, // a textual description of the model, if provided during model creation
  } = summary;

  // You can get the full model info using `getDocumentModel`
  const model = await client.getDocumentModel(modelId);
}

依頁面

// The listDocumentModels method is paged, and you can iterate by page using the `byPage` method.
const pages = client.listDocumentModels().byPage();

for await (const page of pages) {
  // Each page is an array of models and can be iterated synchronously
  for (const model of page) {
    const {
      modelId, // The model's unique ID
      description, // a textual description of the model, if provided during model creation
    } = summary;

    // You can get the full model info using `getDocumentModel`
    const model = await client.getDocumentModel(modelId);
  }
}
function listDocumentModels(options?: ListModelsOptions): PagedAsyncIterableIterator<DocumentModelSummary, DocumentModelSummary[], PageSettings>

參數

options
ListModelsOptions

模型要求的選擇性設定

傳回

支援分頁之模型摘要的非同步反覆運算

listOperations(ListOperationsOptions)

列出資源中的模型建立作業。 這會產生所有作業,包括無法成功建立模型的作業。 此作業支援分頁。

範例

非同步反復專案

for await (const operation of client.listOperations()) {
  const {
    operationId, // the operation's GUID
    status, // the operation status, one of "notStarted", "running", "succeeded", "failed", or "canceled"
    percentCompleted // the progress of the operation, from 0 to 100
  } = operation;
}

依頁面

// The listOperations method is paged, and you can iterate by page using the `byPage` method.
const pages = client.listOperations().byPage();

for await (const page of pages) {
  // Each page is an array of operation info objects and can be iterated synchronously
  for (const operation of page) {
    const {
      operationId, // the operation's GUID
      status, // the operation status, one of "notStarted", "running", "succeeded", "failed", or "canceled"
      percentCompleted // the progress of the operation, from 0 to 100
    } = operation;
  }
}
function listOperations(options?: ListOperationsOptions): PagedAsyncIterableIterator<OperationSummary, OperationSummary[], PageSettings>

參數

options
ListOperationsOptions

作業要求的選擇性設定

傳回

可非同步反覆運算支援分頁的作業資訊物件