DocumentModelAdministrationClient class

Klient pro interakci s funkcemi správy modelů služby Rozpoznávání formulářů, jako je vytváření, čtení, výpis, odstraňování a kopírování modelů.

Příklady:

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

Klíč rozhraní API (klíč předplatného)

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

Konstruktory

DocumentModelAdministrationClient(string, KeyCredential, DocumentModelAdministrationClientOptions)

Vytvoření instance DocumentModelAdministrationClient z koncového bodu prostředku a klíče statického rozhraní API (KeyCredential),

Příklad:

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)

Vytvořte instanci DocumentModelAdministrationClient z koncového bodu prostředku a identity TokenCredentialAzure .

Další informace o ověřování pomocí Azure Active Directory najdete v @azure/identity tomto balíčku.

Příklad:

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

Metody

beginBuildDocumentClassifier(string, DocumentClassifierDocumentTypeSources, BeginBuildDocumentClassifierOptions)

Vytvořte nový klasifikátor dokumentů s daným ID klasifikátoru a typy dokumentů.

ID klasifikátoru musí být mezi klasifikátory v rámci prostředku jedinečné.

Typy dokumentů jsou uvedeny jako objekt, který mapuje název typu dokumentu na trénovací datovou sadu pro daný typ dokumentu. Podporují se dvě metody trénování vstupních dat:

  • azureBlobSource, která trénuje klasifikátor pomocí dat v daném kontejneru Azure Blob Storage.
  • azureBlobFileListSource, která se podobá azureBlobSource , ale umožňuje podrobnější kontrolu nad soubory, které jsou součástí trénovací sady dat, pomocí seznamu souborů ve formátu JSONL.

Služba Rozpoznávání formulářů čte trénovací datovou sadu z kontejneru Azure Storage zadanou jako adresu URL kontejneru pomocí tokenu SAS, který umožňuje komunikaci back-endu služby s kontejnerem. Vyžadují se minimálně oprávnění ke čtení a seznamu. Kromě toho musí být data v daném kontejneru uspořádaná podle konkrétní konvence, která je zdokumentovaná v dokumentaci služby pro vytváření vlastních klasifikátorů dokumentů.

Příklad

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)

Vytvořte nový model s daným ID ze zdroje obsahu modelu.

ID modelu se může skládat z libovolného textu, pokud nezačíná na "předem připravený-" (protože tyto modely odkazují na předem vytvořené Rozpoznávání formulářů modely, které jsou společné pro všechny prostředky) a pokud v rámci prostředku ještě neexistuje.

Zdroj obsahu popisuje mechanismus, který služba použije ke čtení vstupních trénovacích dat. Další informace najdete v tématu typ <xref:DocumentModelContentSource> .

Příklad

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)

Vytvořte nový model s daným ID ze sady vstupních dokumentů a označených polí.

ID modelu se může skládat z libovolného textu, pokud nezačíná na "předem připravený-" (protože tyto modely odkazují na předem vytvořené Rozpoznávání formulářů modely, které jsou společné pro všechny prostředky) a pokud v rámci prostředku ještě neexistuje.

Služba Rozpoznávání formulářů čte trénovací datovou sadu z kontejneru Azure Storage zadanou jako adresu URL kontejneru pomocí tokenu SAS, který umožňuje komunikaci back-endu služby s kontejnerem. Vyžadují se minimálně oprávnění ke čtení a seznamu. Data v daném kontejneru navíc musí být uspořádaná podle konkrétní konvence, která je zdokumentovaná v dokumentaci služby pro vytváření vlastních modelů.

Příklad

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)

Vytvoří jeden složený model z několika předem existujících dílčích modelů.

Výsledný složený model kombinuje typy dokumentů svých modelů komponent a vloží klasifikační krok do kanálu extrakce, aby určil, který z jeho dílčích modelů komponent je pro daný vstup nejvhodnější.

Příklad

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)

Zkopíruje model s daným ID do prostředku a ID modelu kódované danou autorizací kopírování.

Viz CopyAuthorization a getCopyAuthorization.

Příklad

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

Odstraní klasifikátor s daným ID z prostředku klienta, pokud existuje. Tuto operaci NELZE vrátit zpět.

Příklad

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

Odstraní model s daným ID z prostředku klienta, pokud existuje. Tuto operaci NELZE vrátit zpět.

Příklad

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

Vytvoří autorizaci pro zkopírování modelu do prostředku, který se používá s metodou beginCopyModelTo .

Udělí CopyAuthorization jinému prostředku kognitivní služby právo vytvořit model v prostředku tohoto klienta s ID modelu a volitelným popisem, které jsou zakódované do autorizace.

Příklad

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

Načte informace o klasifikátoru (DocumentClassifierDetails) podle ID.

Příklad

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)

Načte informace o modelu (DocumentModelDetails) podle ID.

Tato metoda může načíst informace o vlastních i předem připravených modelech.

Změna způsobující chybu

V předchozích verzích rozhraní ROZPOZNÁVÁNÍ FORMULÁŘŮ REST API a sady SDK getModel mohla metoda vrátit jakýkoli model, i ten, který se kvůli chybám nepodařilo vytvořit. V nových verzích getDocumentModel služeb a listDocumentModelsvytvářejí pouze úspěšně vytvořené modely (tj. modely, které jsou "připravené" k použití). Neúspěšné modely se teď načítají prostřednictvím rozhraní API operací. Viz getOperation a listOperations.

Příklad

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

Načte informace o operaci (OperationDetails) podle jejího ID.

Operace představují úlohy, které nejsou analytické, jako je vytváření, vytváření nebo kopírování modelu.

getResourceDetails(GetResourceDetailsOptions)

Načíst základní informace o prostředku tohoto klienta.

Příklad

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)

Uveďte podrobnosti o klasifikátorech v prostředku. Tato operace podporuje stránkování.

Příklady

Asynchronní iterace

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

Podle stránky

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

Vypíše souhrny modelů v prostředku. Budou zahrnuty vlastní i předem připravené modely. Tato operace podporuje stránkování.

Souhrn modelu (DocumentModelSummary) obsahuje pouze základní informace o modelu a nezahrnuje informace o typech dokumentů v modelu (například schémata polí a hodnoty spolehlivosti).

Pokud chcete získat přístup k úplným informacím o modelu, použijte getDocumentModel.

Změna způsobující chybu

V předchozích verzích rozhraní ROZPOZNÁVÁNÍ FORMULÁŘŮ REST API a sady SDK by metoda vracela všechny modely, a to i ty, listModels které se nepodařilo vytvořit kvůli chybám. V nových verzích listDocumentModels služeb a getDocumentModelvytvářejí pouze úspěšně vytvořené modely (tj. modely, které jsou "připravené" k použití). Neúspěšné modely se teď načítají prostřednictvím rozhraní API operací. Viz getOperation a listOperations.

Příklady

Asynchronní iterace

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

Podle stránky

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

Vypíše operace vytvoření modelu v prostředku. Tím se vytvoří všechny operace, včetně operací, kterým se nepodařilo úspěšně vytvořit modely. Tato operace podporuje stránkování.

Příklady

Asynchronní iterace

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

Podle stránky

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

Podrobnosti konstruktoru

DocumentModelAdministrationClient(string, KeyCredential, DocumentModelAdministrationClientOptions)

Vytvoření instance DocumentModelAdministrationClient z koncového bodu prostředku a klíče statického rozhraní API (KeyCredential),

Příklad:

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)

Parametry

endpoint

string

adresa URL koncového bodu instance služeb Azure Cognitive Services

credential
KeyCredential

KeyCredential obsahující klíč předplatného instance služeb Cognitive Services

options
DocumentModelAdministrationClientOptions

volitelná nastavení pro konfiguraci všech metod v klientovi

DocumentModelAdministrationClient(string, TokenCredential, DocumentModelAdministrationClientOptions)

Vytvořte instanci DocumentModelAdministrationClient z koncového bodu prostředku a identity TokenCredentialAzure .

Další informace o ověřování pomocí Azure Active Directory najdete v @azure/identity tomto balíčku.

Příklad:

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)

Parametry

endpoint

string

adresa URL koncového bodu instance služeb Azure Cognitive Services

credential
TokenCredential

Instance TokenCredential z @azure/identity balíčku

options
DocumentModelAdministrationClientOptions

volitelná nastavení pro konfiguraci všech metod v klientovi

Podrobnosti metody

beginBuildDocumentClassifier(string, DocumentClassifierDocumentTypeSources, BeginBuildDocumentClassifierOptions)

Vytvořte nový klasifikátor dokumentů s daným ID klasifikátoru a typy dokumentů.

ID klasifikátoru musí být mezi klasifikátory v rámci prostředku jedinečné.

Typy dokumentů jsou uvedeny jako objekt, který mapuje název typu dokumentu na trénovací datovou sadu pro daný typ dokumentu. Podporují se dvě metody trénování vstupních dat:

  • azureBlobSource, která trénuje klasifikátor pomocí dat v daném kontejneru Azure Blob Storage.
  • azureBlobFileListSource, která se podobá azureBlobSource , ale umožňuje podrobnější kontrolu nad soubory, které jsou součástí trénovací sady dat, pomocí seznamu souborů ve formátu JSONL.

Služba Rozpoznávání formulářů čte trénovací datovou sadu z kontejneru Azure Storage zadanou jako adresu URL kontejneru pomocí tokenu SAS, který umožňuje komunikaci back-endu služby s kontejnerem. Vyžadují se minimálně oprávnění ke čtení a seznamu. Kromě toho musí být data v daném kontejneru uspořádaná podle konkrétní konvence, která je zdokumentovaná v dokumentaci služby pro vytváření vlastních klasifikátorů dokumentů.

Příklad

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>

Parametry

classifierId

string

jedinečné ID klasifikátoru, který se má vytvořit

docTypeSources
DocumentClassifierDocumentTypeSources

typy dokumentů, které se mají zahrnout do klasifikátoru, a jejich zdroje (mapování názvů typů dokumentů na ClassifierDocumentTypeDetails).

options
BeginBuildDocumentClassifierOptions

volitelná nastavení pro operaci sestavení klasifikátoru

Návraty

dlouhotrvající operace (poller), která nakonec vytvoří vytvořené podrobnosti klasifikátoru nebo chybu

beginBuildDocumentModel(string, DocumentModelSource, DocumentModelBuildMode, BeginBuildDocumentModelOptions)

Vytvořte nový model s daným ID ze zdroje obsahu modelu.

ID modelu se může skládat z libovolného textu, pokud nezačíná na "předem připravený-" (protože tyto modely odkazují na předem vytvořené Rozpoznávání formulářů modely, které jsou společné pro všechny prostředky) a pokud v rámci prostředku ještě neexistuje.

Zdroj obsahu popisuje mechanismus, který služba použije ke čtení vstupních trénovacích dat. Další informace najdete v tématu typ <xref:DocumentModelContentSource> .

Příklad

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>

Parametry

modelId

string

jedinečné ID modelu, který se má vytvořit

contentSource
DocumentModelSource

zdroj obsahu, který poskytuje trénovací data pro tento model

buildMode

DocumentModelBuildMode

režim, který se má použít při vytváření modelu (viz DocumentModelBuildMode).

options
BeginBuildDocumentModelOptions

volitelná nastavení pro operaci sestavení modelu

Návraty

dlouhotrvající operace (poller), která nakonec vygeneruje informace o vytvořeném modelu nebo chybu

beginBuildDocumentModel(string, string, DocumentModelBuildMode, BeginBuildDocumentModelOptions)

Vytvořte nový model s daným ID ze sady vstupních dokumentů a označených polí.

ID modelu se může skládat z libovolného textu, pokud nezačíná na "předem připravený-" (protože tyto modely odkazují na předem vytvořené Rozpoznávání formulářů modely, které jsou společné pro všechny prostředky) a pokud v rámci prostředku ještě neexistuje.

Služba Rozpoznávání formulářů čte trénovací datovou sadu z kontejneru Azure Storage zadanou jako adresu URL kontejneru pomocí tokenu SAS, který umožňuje komunikaci back-endu služby s kontejnerem. Vyžadují se minimálně oprávnění ke čtení a seznamu. Data v daném kontejneru navíc musí být uspořádaná podle konkrétní konvence, která je zdokumentovaná v dokumentaci služby pro vytváření vlastních modelů.

Příklad

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>

Parametry

modelId

string

jedinečné ID modelu, který se má vytvořit

containerUrl

string

Adresa URL zakódovaná jako SAS ke kontejneru Azure Storage, který obsahuje trénovací sadu dat

buildMode

DocumentModelBuildMode

režim, který se má použít při vytváření modelu (viz DocumentModelBuildMode).

options
BeginBuildDocumentModelOptions

volitelná nastavení pro operaci sestavení modelu

Návraty

dlouhotrvající operace (poller), která nakonec vygeneruje informace o vytvořeném modelu nebo chybu

beginComposeDocumentModel(string, Iterable<string>, BeginComposeDocumentModelOptions)

Vytvoří jeden složený model z několika předem existujících dílčích modelů.

Výsledný složený model kombinuje typy dokumentů svých modelů komponent a vloží klasifikační krok do kanálu extrakce, aby určil, který z jeho dílčích modelů komponent je pro daný vstup nejvhodnější.

Příklad

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>

Parametry

modelId

string

jedinečné ID modelu, který se má vytvořit

componentModelIds

Iterable<string>

An Iterable of strings representing the unique model ID of the models to compose

options
BeginComposeDocumentModelOptions

volitelná nastavení pro vytvoření modelu

Návraty

dlouhotrvající operace (poller), která nakonec vygeneruje informace o vytvořeném modelu nebo chybu

beginCopyModelTo(string, CopyAuthorization, BeginCopyModelOptions)

Zkopíruje model s daným ID do prostředku a ID modelu kódované danou autorizací kopírování.

Viz CopyAuthorization a getCopyAuthorization.

Příklad

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

Parametry

sourceModelId

string

jedinečné ID zdrojového modelu, který se zkopíruje

authorization
CopyAuthorization

autorizace ke kopírování modelu vytvořeného pomocí metody getCopyAuthorization

options
BeginCopyModelOptions

volitelná nastavení pro

Návraty

dlouhotrvající operace (poller), která nakonec vygeneruje zkopírované informace o modelu nebo chybu

deleteDocumentClassifier(string, OperationOptions)

Odstraní klasifikátor s daným ID z prostředku klienta, pokud existuje. Tuto operaci NELZE vrátit zpět.

Příklad

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

Parametry

classifierId

string

jedinečné ID klasifikátoru, který se má odstranit z prostředku

options
OperationOptions

volitelná nastavení pro požadavek

Návraty

Promise<void>

deleteDocumentModel(string, DeleteDocumentModelOptions)

Odstraní model s daným ID z prostředku klienta, pokud existuje. Tuto operaci NELZE vrátit zpět.

Příklad

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

Parametry

modelId

string

jedinečné ID modelu, který se má z prostředku odstranit

options
DeleteDocumentModelOptions

volitelná nastavení pro požadavek

Návraty

Promise<void>

getCopyAuthorization(string, GetCopyAuthorizationOptions)

Vytvoří autorizaci pro zkopírování modelu do prostředku, který se používá s metodou beginCopyModelTo .

Udělí CopyAuthorization jinému prostředku kognitivní služby právo vytvořit model v prostředku tohoto klienta s ID modelu a volitelným popisem, které jsou zakódované do autorizace.

Příklad

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

Parametry

destinationModelId

string

jedinečné ID cílového modelu (ID, do které se má model zkopírovat)

options
GetCopyAuthorizationOptions

volitelná nastavení pro vytvoření autorizace kopírování

Návraty

autorizace kopírování, která kóduje dané ID modelu a volitelný popis

getDocumentClassifier(string, OperationOptions)

Načte informace o klasifikátoru (DocumentClassifierDetails) podle ID.

Příklad

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>

Parametry

classifierId

string

jedinečné ID klasifikátoru, který se má dotazovat

options
OperationOptions

volitelná nastavení pro požadavek

Návraty

informace o klasifikátoru s daným ID

getDocumentModel(string, GetModelOptions)

Načte informace o modelu (DocumentModelDetails) podle ID.

Tato metoda může načíst informace o vlastních i předem připravených modelech.

Změna způsobující chybu

V předchozích verzích rozhraní ROZPOZNÁVÁNÍ FORMULÁŘŮ REST API a sady SDK getModel mohla metoda vrátit jakýkoli model, i ten, který se kvůli chybám nepodařilo vytvořit. V nových verzích getDocumentModel služeb a listDocumentModelsvytvářejí pouze úspěšně vytvořené modely (tj. modely, které jsou "připravené" k použití). Neúspěšné modely se teď načítají prostřednictvím rozhraní API operací. Viz getOperation a listOperations.

Příklad

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

Parametry

modelId

string

jedinečné ID modelu, který se má dotazovat

options
GetModelOptions

volitelná nastavení pro požadavek

Návraty

informace o modelu s daným ID

getOperation(string, GetOperationOptions)

Načte informace o operaci (OperationDetails) podle jejího ID.

Operace představují úlohy, které nejsou analytické, jako je vytváření, vytváření nebo kopírování modelu.

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

Parametry

operationId

string

ID operace, která se má dotazovat

options
GetOperationOptions

volitelná nastavení pro požadavek

Návraty

Promise<OperationDetails>

informace o operaci s daným ID

Příklad

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

Načíst základní informace o prostředku tohoto klienta.

Příklad

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>

Parametry

options
GetResourceDetailsOptions

volitelná nastavení pro požadavek

Návraty

Promise<ResourceDetails>

základní informace o prostředku tohoto klienta

listDocumentClassifiers(ListModelsOptions)

Uveďte podrobnosti o klasifikátorech v prostředku. Tato operace podporuje stránkování.

Příklady

Asynchronní iterace

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

Podle stránky

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

Parametry

options
ListModelsOptions

volitelná nastavení pro požadavky klasifikátoru

Návraty

asynchronní iterace podrobností klasifikátoru, která podporuje stránkování

listDocumentModels(ListModelsOptions)

Vypíše souhrny modelů v prostředku. Budou zahrnuty vlastní i předem připravené modely. Tato operace podporuje stránkování.

Souhrn modelu (DocumentModelSummary) obsahuje pouze základní informace o modelu a nezahrnuje informace o typech dokumentů v modelu (například schémata polí a hodnoty spolehlivosti).

Pokud chcete získat přístup k úplným informacím o modelu, použijte getDocumentModel.

Změna způsobující chybu

V předchozích verzích rozhraní ROZPOZNÁVÁNÍ FORMULÁŘŮ REST API a sady SDK by metoda vracela všechny modely, a to i ty, listModels které se nepodařilo vytvořit kvůli chybám. V nových verzích listDocumentModels služeb a getDocumentModelvytvářejí pouze úspěšně vytvořené modely (tj. modely, které jsou "připravené" k použití). Neúspěšné modely se teď načítají prostřednictvím rozhraní API operací. Viz getOperation a listOperations.

Příklady

Asynchronní iterace

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

Podle stránky

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

Parametry

options
ListModelsOptions

volitelná nastavení pro požadavky modelu

Návraty

asynchronní iterable of model summaries that supports paging

listOperations(ListOperationsOptions)

Vypíše operace vytvoření modelu v prostředku. Tím se vytvoří všechny operace, včetně operací, kterým se nepodařilo úspěšně vytvořit modely. Tato operace podporuje stránkování.

Příklady

Asynchronní iterace

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

Podle stránky

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

Parametry

options
ListOperationsOptions

volitelná nastavení pro požadavky na operace

Návraty

asynchronní iterovatelné objekty informací o operacích, které podporují stránkování