DocumentModelAdministrationClient class

Klien untuk berinteraksi dengan fitur manajemen model layanan Form Recognizer, seperti membuat, membaca, mencantumkan, menghapus, dan menyalin model.

Contoh:

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);

Kunci API (Kunci Langganan)

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);

Konstruktor

DocumentModelAdministrationClient(string, KeyCredential, DocumentModelAdministrationClientOptions)

Membuat instans DocumentModelAdministrationClient dari titik akhir sumber daya dan kunci API statis (KeyCredential),

Contoh:

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)

Buat instans DocumentModelAdministrationClient dari titik akhir sumber daya dan Azure Identity TokenCredential.

@azure/identity Lihat paket untuk informasi selengkapnya tentang mengautentikasi dengan Azure Active Directory.

Contoh:

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);

Metode

beginBuildDocumentClassifier(string, DocumentClassifierDocumentTypeSources, BeginBuildDocumentClassifierOptions)

Buat pengklasifikasi dokumen baru dengan ID pengklasifikasi dan jenis dokumen yang diberikan.

ID pengklasifikasi harus unik di antara pengklasifikasi dalam sumber daya.

Jenis dokumen diberikan sebagai objek yang memetakan nama jenis dokumen ke himpunan data pelatihan untuk jenis dokumen tersebut. Dua metode input data pelatihan didukung:

  • azureBlobSource, yang melatih pengklasifikasi menggunakan data dalam kontainer Azure Blob Storage yang diberikan.
  • azureBlobFileListSource, yang mirip azureBlobSource dengan tetapi memungkinkan kontrol yang lebih halus atas file yang disertakan dalam himpunan data pelatihan dengan menggunakan daftar file berformat JSONL.

Layanan Form Recognizer membaca himpunan data pelatihan dari kontainer Azure Storage, yang diberikan sebagai URL ke kontainer dengan token SAS yang memungkinkan backend layanan berkomunikasi dengan kontainer. Minimal, izin "baca" dan "daftar" diperlukan. Selain itu, data dalam kontainer yang diberikan harus diatur sesuai dengan konvensi tertentu, yang didokumenkan dalam dokumentasi layanan untuk membangun pengklasifikasi dokumen kustom.

Contoh

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)

Buat model baru dengan ID tertentu dari sumber konten model.

ID Model dapat terdiri dari teks apa pun, selama tidak dimulai dengan "bawaan-" (karena model ini mengacu pada model Form Recognizer bawaan yang umum untuk semua sumber daya), dan selama belum ada dalam sumber daya.

Sumber konten menjelaskan mekanisme yang akan digunakan layanan untuk membaca data pelatihan input. <xref:DocumentModelContentSource> Lihat jenis untuk informasi selengkapnya.

Contoh

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)

Buat model baru dengan ID tertentu dari sekumpulan dokumen input dan bidang berlabel.

ID Model dapat terdiri dari teks apa pun, selama tidak dimulai dengan "bawaan-" (karena model ini mengacu pada model Form Recognizer bawaan yang umum untuk semua sumber daya), dan selama belum ada dalam sumber daya.

Layanan Form Recognizer membaca himpunan data pelatihan dari kontainer Azure Storage, yang diberikan sebagai URL ke kontainer dengan token SAS yang memungkinkan backend layanan berkomunikasi dengan kontainer. Minimal, izin "baca" dan "daftar" diperlukan. Selain itu, data dalam kontainer yang diberikan harus diatur sesuai dengan konvensi tertentu, yang didokumenkan dalam dokumentasi layanan untuk membangun model kustom.

Contoh

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)

Membuat satu model yang disusun dari beberapa submodel yang sudah ada sebelumnya.

Model yang disusun yang dihasilkan menggabungkan jenis dokumen model komponennya, dan menyisipkan langkah klasifikasi ke dalam alur ekstraksi untuk menentukan submodel komponen mana yang paling sesuai untuk input yang diberikan.

Contoh

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)

Menyalin model dengan ID yang diberikan ke dalam sumber daya dan ID model yang dikodekan oleh otorisasi salinan tertentu.

Lihat CopyAuthorization dan getCopyAuthorization.

Contoh

// 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)

Menghapus pengklasifikasi dengan ID yang diberikan dari sumber daya klien, jika ada. Operasi ini TIDAK DAPAT dikembalikan.

Contoh

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

Menghapus model dengan ID yang diberikan dari sumber daya klien, jika ada. Operasi ini TIDAK DAPAT dikembalikan.

Contoh

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

Membuat otorisasi untuk menyalin model ke dalam sumber daya, digunakan dengan beginCopyModelTo metode .

CopyAuthorization memberikan sumber daya layanan kognitif lain hak untuk membuat model di sumber daya klien ini dengan ID model dan deskripsi opsional yang dikodekan ke dalam otorisasi.

Contoh

// 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)

Mengambil informasi tentang pengklasifikasi (DocumentClassifierDetails) berdasarkan ID.

Contoh

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)

Mengambil informasi tentang model (DocumentModelDetails) berdasarkan ID.

Metode ini dapat mengambil informasi tentang model kustom serta bawaan.

Melanggar Perubahan

Dalam versi Form Recognizer REST API dan SDK sebelumnya, metode ini getModel dapat mengembalikan model apa pun, bahkan yang gagal dibuat karena kesalahan. Dalam versi layanan baru, getDocumentModel dan listDocumentModelshanya menghasilkan model yang berhasil dibuat (yaitu model yang "siap" untuk digunakan). Model yang gagal sekarang diambil melalui API "operasi", lihat getOperation dan listOperations.

Contoh

// 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)

Mengambil informasi tentang operasi (OperationDetails) dengan ID-nya.

Operasi mewakili tugas non-analisis, seperti membangun, menyusun, atau menyalin model.

getResourceDetails(GetResourceDetailsOptions)

Ambil informasi dasar tentang sumber daya klien ini.

Contoh

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)

Mencantumkan detail tentang pengklasifikasi dalam sumber daya. Operasi ini mendukung halaman.

Contoh

Perulangan Asinkron

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;
}

Menurut Halaman

// 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)

Mencantumkan ringkasan model dalam sumber daya. Model kustom serta bawaan akan disertakan. Operasi ini mendukung halaman.

Ringkasan model (DocumentModelSummary) hanya menyertakan informasi dasar tentang model, dan tidak menyertakan informasi tentang jenis dokumen dalam model (seperti skema bidang dan nilai keyakinan).

Untuk mengakses informasi lengkap tentang model, gunakan getDocumentModel.

Melanggar Perubahan

Dalam versi Form Recognizer REST API dan SDK sebelumnya, metode ini listModels akan mengembalikan semua model, bahkan yang gagal dibuat karena kesalahan. Dalam versi layanan baru, listDocumentModels dan getDocumentModelhanya menghasilkan model yang berhasil dibuat (yaitu model yang "siap" untuk digunakan). Model yang gagal sekarang diambil melalui API "operasi", lihat getOperation dan listOperations.

Contoh

Perulangan Asinkron

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);
}

Menurut Halaman

// 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)

Mencantumkan operasi pembuatan model di sumber daya. Ini akan menghasilkan semua operasi, termasuk operasi yang gagal membuat model dengan sukses. Operasi ini mendukung halaman.

Contoh

Perulangan Asinkron

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;
}

Menurut Halaman

// 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;
  }
}

Detail Konstruktor

DocumentModelAdministrationClient(string, KeyCredential, DocumentModelAdministrationClientOptions)

Membuat instans DocumentModelAdministrationClient dari titik akhir sumber daya dan kunci API statis (KeyCredential),

Contoh:

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)

Parameter

endpoint

string

URL titik akhir instans Azure Cognitive Services

credential
KeyCredential

KeyCredential yang berisi kunci langganan instans Cognitive Services

options
DocumentModelAdministrationClientOptions

pengaturan opsional untuk mengonfigurasi semua metode di klien

DocumentModelAdministrationClient(string, TokenCredential, DocumentModelAdministrationClientOptions)

Buat instans DocumentModelAdministrationClient dari titik akhir sumber daya dan Azure Identity TokenCredential.

@azure/identity Lihat paket untuk informasi selengkapnya tentang mengautentikasi dengan Azure Active Directory.

Contoh:

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)

Parameter

endpoint

string

URL titik akhir instans Azure Cognitive Services

credential
TokenCredential

instans TokenCredential dari @azure/identity paket

options
DocumentModelAdministrationClientOptions

pengaturan opsional untuk mengonfigurasi semua metode di klien

Detail Metode

beginBuildDocumentClassifier(string, DocumentClassifierDocumentTypeSources, BeginBuildDocumentClassifierOptions)

Buat pengklasifikasi dokumen baru dengan ID pengklasifikasi dan jenis dokumen yang diberikan.

ID pengklasifikasi harus unik di antara pengklasifikasi dalam sumber daya.

Jenis dokumen diberikan sebagai objek yang memetakan nama jenis dokumen ke himpunan data pelatihan untuk jenis dokumen tersebut. Dua metode input data pelatihan didukung:

  • azureBlobSource, yang melatih pengklasifikasi menggunakan data dalam kontainer Azure Blob Storage yang diberikan.
  • azureBlobFileListSource, yang mirip azureBlobSource dengan tetapi memungkinkan kontrol yang lebih halus atas file yang disertakan dalam himpunan data pelatihan dengan menggunakan daftar file berformat JSONL.

Layanan Form Recognizer membaca himpunan data pelatihan dari kontainer Azure Storage, yang diberikan sebagai URL ke kontainer dengan token SAS yang memungkinkan backend layanan berkomunikasi dengan kontainer. Minimal, izin "baca" dan "daftar" diperlukan. Selain itu, data dalam kontainer yang diberikan harus diatur sesuai dengan konvensi tertentu, yang didokumenkan dalam dokumentasi layanan untuk membangun pengklasifikasi dokumen kustom.

Contoh

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>

Parameter

classifierId

string

ID unik pengklasifikasi untuk dibuat

docTypeSources
DocumentClassifierDocumentTypeSources

jenis dokumen untuk disertakan dalam pengklasifikasi dan sumbernya (peta nama jenis dokumen ke ClassifierDocumentTypeDetails)

options
BeginBuildDocumentClassifierOptions

pengaturan opsional untuk operasi build pengklasifikasi

Mengembalikan

operasi jangka panjang (poller) yang pada akhirnya akan menghasilkan detail pengklasifikasi yang dibuat atau kesalahan

beginBuildDocumentModel(string, DocumentModelSource, DocumentModelBuildMode, BeginBuildDocumentModelOptions)

Buat model baru dengan ID tertentu dari sumber konten model.

ID Model dapat terdiri dari teks apa pun, selama tidak dimulai dengan "bawaan-" (karena model ini mengacu pada model Form Recognizer bawaan yang umum untuk semua sumber daya), dan selama belum ada dalam sumber daya.

Sumber konten menjelaskan mekanisme yang akan digunakan layanan untuk membaca data pelatihan input. <xref:DocumentModelContentSource> Lihat jenis untuk informasi selengkapnya.

Contoh

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>

Parameter

modelId

string

ID unik model yang akan dibuat

contentSource
DocumentModelSource

sumber konten yang menyediakan data pelatihan untuk model ini

buildMode

DocumentModelBuildMode

mode yang akan digunakan saat membangun model (lihat DocumentModelBuildMode)

options
BeginBuildDocumentModelOptions

pengaturan opsional untuk operasi build model

Mengembalikan

operasi jangka panjang (poller) yang akhirnya akan menghasilkan informasi model yang dibuat atau kesalahan

beginBuildDocumentModel(string, string, DocumentModelBuildMode, BeginBuildDocumentModelOptions)

Buat model baru dengan ID tertentu dari sekumpulan dokumen input dan bidang berlabel.

ID Model dapat terdiri dari teks apa pun, selama tidak dimulai dengan "bawaan-" (karena model ini mengacu pada model Form Recognizer bawaan yang umum untuk semua sumber daya), dan selama belum ada dalam sumber daya.

Layanan Form Recognizer membaca himpunan data pelatihan dari kontainer Azure Storage, yang diberikan sebagai URL ke kontainer dengan token SAS yang memungkinkan backend layanan berkomunikasi dengan kontainer. Minimal, izin "baca" dan "daftar" diperlukan. Selain itu, data dalam kontainer yang diberikan harus diatur sesuai dengan konvensi tertentu, yang didokumenkan dalam dokumentasi layanan untuk membangun model kustom.

Contoh

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>

Parameter

modelId

string

ID unik model yang akan dibuat

containerUrl

string

URL yang dikodekan SAS ke kontainer Azure Storage yang menyimpan himpunan data pelatihan

buildMode

DocumentModelBuildMode

mode yang akan digunakan saat membangun model (lihat DocumentModelBuildMode)

options
BeginBuildDocumentModelOptions

pengaturan opsional untuk operasi build model

Mengembalikan

operasi jangka panjang (poller) yang akhirnya akan menghasilkan informasi model yang dibuat atau kesalahan

beginComposeDocumentModel(string, Iterable<string>, BeginComposeDocumentModelOptions)

Membuat satu model yang disusun dari beberapa submodel yang sudah ada sebelumnya.

Model yang disusun yang dihasilkan menggabungkan jenis dokumen model komponennya, dan menyisipkan langkah klasifikasi ke dalam alur ekstraksi untuk menentukan submodel komponen mana yang paling sesuai untuk input yang diberikan.

Contoh

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>

Parameter

modelId

string

ID unik model yang akan dibuat

componentModelIds

Iterable<string>

Iterable string yang mewakili ID model unik dari model untuk disusun

options
BeginComposeDocumentModelOptions

pengaturan opsional untuk pembuatan model

Mengembalikan

operasi jangka panjang (poller) yang akhirnya akan menghasilkan informasi model yang dibuat atau kesalahan

beginCopyModelTo(string, CopyAuthorization, BeginCopyModelOptions)

Menyalin model dengan ID yang diberikan ke dalam sumber daya dan ID model yang dikodekan oleh otorisasi salinan tertentu.

Lihat CopyAuthorization dan getCopyAuthorization.

Contoh

// 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>

Parameter

sourceModelId

string

ID unik model sumber yang akan disalin

authorization
CopyAuthorization

otorisasi untuk menyalin model, dibuat menggunakan getCopyAuthorization

options
BeginCopyModelOptions

pengaturan opsional untuk

Mengembalikan

operasi jangka panjang (poller) yang pada akhirnya akan menghasilkan informasi model yang disalin atau kesalahan

deleteDocumentClassifier(string, OperationOptions)

Menghapus pengklasifikasi dengan ID yang diberikan dari sumber daya klien, jika ada. Operasi ini TIDAK DAPAT dikembalikan.

Contoh

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

Parameter

classifierId

string

ID unik pengklasifikasi untuk dihapus dari sumber daya

options
OperationOptions

pengaturan opsional untuk permintaan

Mengembalikan

Promise<void>

deleteDocumentModel(string, DeleteDocumentModelOptions)

Menghapus model dengan ID yang diberikan dari sumber daya klien, jika ada. Operasi ini TIDAK DAPAT dikembalikan.

Contoh

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

Parameter

modelId

string

ID unik model yang akan dihapus dari sumber daya

options
DeleteDocumentModelOptions

pengaturan opsional untuk permintaan

Mengembalikan

Promise<void>

getCopyAuthorization(string, GetCopyAuthorizationOptions)

Membuat otorisasi untuk menyalin model ke dalam sumber daya, digunakan dengan beginCopyModelTo metode .

CopyAuthorization memberikan sumber daya layanan kognitif lain hak untuk membuat model di sumber daya klien ini dengan ID model dan deskripsi opsional yang dikodekan ke dalam otorisasi.

Contoh

// 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>

Parameter

destinationModelId

string

ID unik model tujuan (ID untuk menyalin model)

options
GetCopyAuthorizationOptions

pengaturan opsional untuk membuat otorisasi salinan

Mengembalikan

otorisasi salinan yang mengodekan modelId yang diberikan dan deskripsi opsional

getDocumentClassifier(string, OperationOptions)

Mengambil informasi tentang pengklasifikasi (DocumentClassifierDetails) berdasarkan ID.

Contoh

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>

Parameter

classifierId

string

ID unik pengklasifikasi untuk kueri

options
OperationOptions

pengaturan opsional untuk permintaan

Mengembalikan

informasi tentang pengklasifikasi dengan ID yang diberikan

getDocumentModel(string, GetModelOptions)

Mengambil informasi tentang model (DocumentModelDetails) berdasarkan ID.

Metode ini dapat mengambil informasi tentang model kustom serta bawaan.

Melanggar Perubahan

Dalam versi Form Recognizer REST API dan SDK sebelumnya, metode ini getModel dapat mengembalikan model apa pun, bahkan yang gagal dibuat karena kesalahan. Dalam versi layanan baru, getDocumentModel dan listDocumentModelshanya menghasilkan model yang berhasil dibuat (yaitu model yang "siap" untuk digunakan). Model yang gagal sekarang diambil melalui API "operasi", lihat getOperation dan listOperations.

Contoh

// 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>

Parameter

modelId

string

ID unik model yang akan dikueri

options
GetModelOptions

pengaturan opsional untuk permintaan

Mengembalikan

informasi tentang model dengan ID yang diberikan

getOperation(string, GetOperationOptions)

Mengambil informasi tentang operasi (OperationDetails) dengan ID-nya.

Operasi mewakili tugas non-analisis, seperti membangun, menyusun, atau menyalin model.

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

Parameter

operationId

string

ID operasi yang akan dikueri

options
GetOperationOptions

pengaturan opsional untuk permintaan

Mengembalikan

Promise<OperationDetails>

informasi tentang operasi dengan ID yang diberikan

Contoh

// 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)

Ambil informasi dasar tentang sumber daya klien ini.

Contoh

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>

Parameter

options
GetResourceDetailsOptions

pengaturan opsional untuk permintaan

Mengembalikan

Promise<ResourceDetails>

informasi dasar tentang sumber daya klien ini

listDocumentClassifiers(ListModelsOptions)

Mencantumkan detail tentang pengklasifikasi dalam sumber daya. Operasi ini mendukung halaman.

Contoh

Perulangan Asinkron

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;
}

Menurut Halaman

// 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>

Parameter

options
ListModelsOptions

pengaturan opsional untuk permintaan pengklasifikasi

Mengembalikan

asinkron yang dapat diulang dari detail pengklasifikasi yang mendukung paging

listDocumentModels(ListModelsOptions)

Mencantumkan ringkasan model dalam sumber daya. Model kustom serta bawaan akan disertakan. Operasi ini mendukung halaman.

Ringkasan model (DocumentModelSummary) hanya menyertakan informasi dasar tentang model, dan tidak menyertakan informasi tentang jenis dokumen dalam model (seperti skema bidang dan nilai keyakinan).

Untuk mengakses informasi lengkap tentang model, gunakan getDocumentModel.

Melanggar Perubahan

Dalam versi Form Recognizer REST API dan SDK sebelumnya, metode ini listModels akan mengembalikan semua model, bahkan yang gagal dibuat karena kesalahan. Dalam versi layanan baru, listDocumentModels dan getDocumentModelhanya menghasilkan model yang berhasil dibuat (yaitu model yang "siap" untuk digunakan). Model yang gagal sekarang diambil melalui API "operasi", lihat getOperation dan listOperations.

Contoh

Perulangan Asinkron

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);
}

Menurut Halaman

// 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>

Parameter

options
ListModelsOptions

pengaturan opsional untuk permintaan model

Mengembalikan

perulangan asinkron ringkasan model yang mendukung penomor

listOperations(ListOperationsOptions)

Mencantumkan operasi pembuatan model di sumber daya. Ini akan menghasilkan semua operasi, termasuk operasi yang gagal membuat model dengan sukses. Operasi ini mendukung halaman.

Contoh

Perulangan Asinkron

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;
}

Menurut Halaman

// 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>

Parameter

options
ListOperationsOptions

pengaturan opsional untuk permintaan operasi

Mengembalikan

asinkron yang dapat diulang dari objek informasi operasi yang mendukung penomor