DocumentModelAdministrationClient class

Ein Client für die Interaktion mit den Modellverwaltungsfeatures des Formularerkennung Diensts, z. B. Erstellen, Lesen, Auflisten, Löschen und Kopieren von Modellen.

Beispiele:

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-Schlüssel (Abonnementschlüssel)

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

Konstruktoren

DocumentModelAdministrationClient(string, KeyCredential, DocumentModelAdministrationClientOptions)

Erstellen eines DocumentModelAdministrationClient-instance aus einem Ressourcenendpunkt und einem statischen API-Schlüssel (KeyCredential),

Beispiel:

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)

Erstellen Sie eine DocumentModelAdministrationClient-instance aus einem Ressourcenendpunkt und einer Azure IdentityTokenCredential.

Weitere Informationen zur Authentifizierung mit Azure Active Directory finden Sie im @azure/identity Paket.

Beispiel:

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

Methoden

beginBuildDocumentClassifier(string, DocumentClassifierDocumentTypeSources, BeginBuildDocumentClassifierOptions)

Erstellen Sie eine neue Dokumentklassifizierung mit der angegebenen Klassifizierer-ID und den angegebenen Dokumenttypen.

Die Klassifizierer-ID muss unter Klassifizierern innerhalb der Ressource eindeutig sein.

Die Dokumenttypen werden als Objekt angegeben, das den Namen des Dokumenttyps dem Trainingsdataset für diesen Dokumenttyp zuordnet. Zwei Methoden zur Eingabe von Trainingsdaten werden unterstützt:

  • azureBlobSource, der einen Klassifizierer unter Verwendung der Daten im angegebenen Azure Blob Storage-Container trainiert.
  • azureBlobFileListSource, das ähnlich azureBlobSource ist, aber eine präzisere Steuerung der Dateien ermöglicht, die im Trainingsdataset enthalten sind, indem eine Dateiliste im JSONL-Format verwendet wird.

Der Formularerkennung-Dienst liest das Trainingsdataset aus einem Azure Storage-Container, der als URL für den Container mit einem SAS-Token angegeben wird, mit dem das Dienst-Back-End mit dem Container kommunizieren kann. Mindestens die Berechtigungen "lesen" und "list" sind erforderlich. Darüber hinaus müssen die Daten im angegebenen Container gemäß einer bestimmten Konvention organisiert werden, die in der Dokumentation des Diensts zum Erstellen benutzerdefinierter Dokumentklassifizierer dokumentiert ist.

Beispiel

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)

Erstellen Sie ein neues Modell mit einer bestimmten ID aus einer Modellinhaltsquelle.

Die Modell-ID kann aus beliebigem Text bestehen, solange sie nicht mit "vordefinierten" beginnt (da sich diese Modelle auf vordefinierte Formularerkennung Modelle beziehen, die für alle Ressourcen gemeinsam sind), und solange sie nicht bereits innerhalb der Ressource vorhanden ist.

Die Inhaltsquelle beschreibt den Mechanismus, den der Dienst zum Lesen der Eingabetrainingsdaten verwendet. Weitere Informationen finden Sie im <xref:DocumentModelContentSource> Typ.

Beispiel

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)

Erstellen Sie ein neues Modell mit einer angegebenen ID aus einem Satz von Eingabedokumenten und beschrifteten Feldern.

Die Modell-ID kann aus beliebigem Text bestehen, solange sie nicht mit "vordefinierten" beginnt (da sich diese Modelle auf vordefinierte Formularerkennung Modelle beziehen, die für alle Ressourcen gemeinsam sind), und solange sie nicht bereits innerhalb der Ressource vorhanden ist.

Der Formularerkennung-Dienst liest das Trainingsdataset aus einem Azure Storage-Container, der als URL für den Container mit einem SAS-Token angegeben wird, mit dem das Dienst-Back-End mit dem Container kommunizieren kann. Mindestens sind die Berechtigungen "Lesen" und "Listen" erforderlich. Darüber hinaus müssen die Daten im angegebenen Container nach einer bestimmten Konvention organisiert werden, die in der Dokumentation des Diensts zum Erstellen benutzerdefinierter Modelle dokumentiert ist.

Beispiel

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)

Erstellt ein einzelnes zusammengesetztes Modell aus mehreren bereits vorhandenen Untermodellen.

Das resultierende zusammengesetzte Modell kombiniert die Dokumenttypen seiner Komponentenmodelle und fügt einen Klassifizierungsschritt in die Extraktionspipeline ein, um zu bestimmen, welches seiner Komponentenuntermodelle für die angegebene Eingabe am besten geeignet ist.

Beispiel

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)

Kopiert ein Modell mit der angegebenen ID in die Ressource und modell-ID, die durch eine bestimmte Kopierautorisierung codiert ist.

Weitere Informationen finden Sie unter CopyAuthorization und getCopyAuthorization.

Beispiel

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

Löscht einen Klassifizierer mit der angegebenen ID aus der Ressource des Clients, sofern vorhanden. Dieser Vorgang KANN NICHT wiederhergestellt werden.

Beispiel

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

Löscht ein Modell mit der angegebenen ID aus der Ressource des Clients, sofern vorhanden. Dieser Vorgang KANN NICHT wiederhergestellt werden.

Beispiel

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

Erstellt eine Autorisierung zum Kopieren eines Modells in die Ressource, die mit der beginCopyModelTo -Methode verwendet wird.

Die CopyAuthorization gewährt einer anderen Cognitive Service-Ressource das Recht, ein Modell in der Ressource dieses Clients mit der Modell-ID und der optionalen Beschreibung zu erstellen, die in die Autorisierung codiert sind.

Beispiel

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

Ruft Informationen zu einem Klassifizierer (DocumentClassifierDetails) nach ID ab.

Beispiel

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)

Ruft Informationen zu einem Modell (DocumentModelDetails) nach ID ab.

Diese Methode kann Informationen zu benutzerdefinierten und vordefinierten Modellen abrufen.

Breaking Change

In früheren Versionen der Formularerkennung REST-API und sdk konnte die getModel -Methode jedes Modell zurückgeben, auch eines, das aufgrund von Fehlern nicht erstellt werden konnte. Erstellen Sie in den neuen Dienstversionen nur erfolgreich erstellte Modelle (d. h. Modelle, getDocumentModellistDocumentModels die "bereit" für die Verwendung sind). Fehlerhafte Modelle werden jetzt über die "Operations"-APIs abgerufen. Weitere Informationen finden Sie unter getOperation und listOperations.

Beispiel

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

Ruft Informationen zu einem Vorgang (OperationDetails) anhand seiner ID ab.

Vorgänge stellen Nicht-Analyseaufgaben dar, z. B. das Erstellen, Komponieren oder Kopieren eines Modells.

getResourceDetails(GetResourceDetailsOptions)

Rufen Sie grundlegende Informationen zur Ressource dieses Clients ab.

Beispiel

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)

Auflisten von Details zu Klassifizierern in der Ressource. Dieser Vorgang unterstützt das Paging.

Beispiele

Asynchrone Iteration

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

Seite nach Seite

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

Listen Sie Zusammenfassungen von Modellen in der Ressource auf. Benutzerdefinierte sowie vordefinierte Modelle sind enthalten. Dieser Vorgang unterstützt das Paging.

Die Modellzusammenfassung (DocumentModelSummary) enthält nur die grundlegenden Informationen zum Modell und enthält keine Informationen zu den Dokumenttypen im Modell (z. B. feldschemas und Konfidenzwerte).

Verwenden Sie getDocumentModel, um auf die vollständigen Informationen zum Modell zuzugreifen.

Breaking Change

In früheren Versionen der Formularerkennung REST-API und sdk hat die listModels Methode alle Modelle zurückgegeben, auch die Modelle, die aufgrund von Fehlern nicht erstellt werden konnten. Erstellen Sie in den neuen Dienstversionen nur erfolgreich erstellte Modelle (d. h. Modelle, listDocumentModelsgetDocumentModel die "bereit" für die Verwendung sind). Fehlerhafte Modelle werden jetzt über die "Operations"-APIs abgerufen. Weitere Informationen finden Sie unter getOperation und listOperations.

Beispiele

Asynchrone Iteration

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

Seite nach Seite

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

Auflisten von Modellerstellungsvorgängen in der Ressource. Dadurch werden alle Vorgänge generiert, einschließlich Vorgängen, die nicht erfolgreich Modelle erstellt haben. Dieser Vorgang unterstützt das Paging.

Beispiele

Asynchrone Iteration

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

Seite nach Seite

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

Details zum Konstruktor

DocumentModelAdministrationClient(string, KeyCredential, DocumentModelAdministrationClientOptions)

Erstellen eines DocumentModelAdministrationClient-instance aus einem Ressourcenendpunkt und einem statischen API-Schlüssel (KeyCredential),

Beispiel:

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

Die Endpunkt-URL einer Azure Cognitive Services-instance

credential
KeyCredential

KeyCredential mit dem Cognitive Services-instance-Abonnementschlüssel

options
DocumentModelAdministrationClientOptions

optionale Einstellungen zum Konfigurieren aller Methoden im Client

DocumentModelAdministrationClient(string, TokenCredential, DocumentModelAdministrationClientOptions)

Erstellen Sie eine DocumentModelAdministrationClient-instance aus einem Ressourcenendpunkt und einer Azure IdentityTokenCredential.

Weitere Informationen zur Authentifizierung mit Azure Active Directory finden Sie im @azure/identity Paket.

Beispiel:

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

Die Endpunkt-URL einer Azure Cognitive Services-instance

credential
TokenCredential

ein tokenCredential-instance aus dem @azure/identity Paket

options
DocumentModelAdministrationClientOptions

optionale Einstellungen zum Konfigurieren aller Methoden im Client

Details zur Methode

beginBuildDocumentClassifier(string, DocumentClassifierDocumentTypeSources, BeginBuildDocumentClassifierOptions)

Erstellen Sie eine neue Dokumentklassifizierung mit der angegebenen Klassifizierer-ID und den angegebenen Dokumenttypen.

Die Klassifizierer-ID muss unter Klassifizierern innerhalb der Ressource eindeutig sein.

Die Dokumenttypen werden als Objekt angegeben, das den Namen des Dokumenttyps dem Trainingsdataset für diesen Dokumenttyp zuordnet. Zwei Methoden zur Eingabe von Trainingsdaten werden unterstützt:

  • azureBlobSource, der einen Klassifizierer unter Verwendung der Daten im angegebenen Azure Blob Storage-Container trainiert.
  • azureBlobFileListSource, das ähnlich azureBlobSource ist, aber eine präzisere Steuerung der Dateien ermöglicht, die im Trainingsdataset enthalten sind, indem eine Dateiliste im JSONL-Format verwendet wird.

Der Formularerkennung-Dienst liest das Trainingsdataset aus einem Azure Storage-Container, der als URL für den Container mit einem SAS-Token angegeben wird, mit dem das Dienst-Back-End mit dem Container kommunizieren kann. Mindestens die Berechtigungen "lesen" und "list" sind erforderlich. Darüber hinaus müssen die Daten im angegebenen Container gemäß einer bestimmten Konvention organisiert werden, die in der Dokumentation des Diensts zum Erstellen benutzerdefinierter Dokumentklassifizierer dokumentiert ist.

Beispiel

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

die eindeutige ID des zu erstellenden Klassifizierers

docTypeSources
DocumentClassifierDocumentTypeSources

die Dokumenttypen, die in die Klassifizierung eingeschlossen werden sollen, und deren Quellen (eine Zuordnung von Dokumenttypnamen zu ClassifierDocumentTypeDetails)

options
BeginBuildDocumentClassifierOptions

optionale Einstellungen für den Klassifizierer-Buildvorgang

Gibt zurück

Ein Zeitintensiver Vorgang (Poller), der schließlich die erstellten Klassifiziererdetails oder einen Fehler erzeugt.

beginBuildDocumentModel(string, DocumentModelSource, DocumentModelBuildMode, BeginBuildDocumentModelOptions)

Erstellen Sie ein neues Modell mit einer bestimmten ID aus einer Modellinhaltsquelle.

Die Modell-ID kann aus beliebigem Text bestehen, solange sie nicht mit "vordefinierten" beginnt (da sich diese Modelle auf vordefinierte Formularerkennung Modelle beziehen, die für alle Ressourcen gemeinsam sind), und solange sie nicht bereits innerhalb der Ressource vorhanden ist.

Die Inhaltsquelle beschreibt den Mechanismus, den der Dienst zum Lesen der Eingabetrainingsdaten verwendet. Weitere Informationen finden Sie im <xref:DocumentModelContentSource> Typ.

Beispiel

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

die eindeutige ID des zu erstellenden Modells

contentSource
DocumentModelSource

Eine Inhaltsquelle, die die Trainingsdaten für dieses Modell bereitstellt

buildMode

DocumentModelBuildMode

der Beim Erstellen des Modells zu verwendende Modus (siehe DocumentModelBuildMode)

options
BeginBuildDocumentModelOptions

optionale Einstellungen für den Modellbuildvorgang

Gibt zurück

Ein zeitintensiver Vorgang (Poller), der schließlich die erstellten Modellinformationen oder einen Fehler erzeugt.

beginBuildDocumentModel(string, string, DocumentModelBuildMode, BeginBuildDocumentModelOptions)

Erstellen Sie ein neues Modell mit einer angegebenen ID aus einem Satz von Eingabedokumenten und beschrifteten Feldern.

Die Modell-ID kann aus beliebigem Text bestehen, solange sie nicht mit "vordefinierten" beginnt (da sich diese Modelle auf vordefinierte Formularerkennung Modelle beziehen, die für alle Ressourcen gemeinsam sind), und solange sie nicht bereits innerhalb der Ressource vorhanden ist.

Der Formularerkennung-Dienst liest das Trainingsdataset aus einem Azure Storage-Container, der als URL für den Container mit einem SAS-Token angegeben wird, mit dem das Dienst-Back-End mit dem Container kommunizieren kann. Mindestens sind die Berechtigungen "Lesen" und "Listen" erforderlich. Darüber hinaus müssen die Daten im angegebenen Container nach einer bestimmten Konvention organisiert werden, die in der Dokumentation des Diensts zum Erstellen benutzerdefinierter Modelle dokumentiert ist.

Beispiel

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

die eindeutige ID des zu erstellenden Modells

containerUrl

string

SAS-codierte URL zu einem Azure Storage-Container mit dem Trainingsdatensatz

buildMode

DocumentModelBuildMode

der Beim Erstellen des Modells zu verwendende Modus (siehe DocumentModelBuildMode)

options
BeginBuildDocumentModelOptions

optionale Einstellungen für den Modellbuildvorgang

Gibt zurück

ein Vorgang mit langer Ausführungsdauer (Poller), der schließlich die erstellten Modellinformationen oder einen Fehler erzeugt

beginComposeDocumentModel(string, Iterable<string>, BeginComposeDocumentModelOptions)

Erstellt ein einzelnes zusammengesetztes Modell aus mehreren bereits vorhandenen Untermodellen.

Das resultierende zusammengesetzte Modell kombiniert die Dokumenttypen seiner Komponentenmodelle und fügt einen Klassifizierungsschritt in die Extraktionspipeline ein, um zu bestimmen, welches seiner Komponentenuntermodelle für die angegebene Eingabe am besten geeignet ist.

Beispiel

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

die eindeutige ID des zu erstellenden Modells

componentModelIds

Iterable<string>

eine Iterable von Zeichenfolgen, die die eindeutigen Modell-IDs der zu erstellenden Modelle darstellen

options
BeginComposeDocumentModelOptions

optionale Einstellungen für die Modellerstellung

Gibt zurück

ein Vorgang mit langer Ausführungsdauer (Poller), der schließlich die erstellten Modellinformationen oder einen Fehler erzeugt

beginCopyModelTo(string, CopyAuthorization, BeginCopyModelOptions)

Kopiert ein Modell mit der angegebenen ID in die Ressource und modell-ID, die durch eine bestimmte Kopierautorisierung codiert ist.

Weitere Informationen finden Sie unter CopyAuthorization und getCopyAuthorization.

Beispiel

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

die eindeutige ID des Quellmodells, das kopiert wird

authorization
CopyAuthorization

eine Autorisierung zum Kopieren des Modells, die mit der getCopyAuthorization erstellt wurde

options
BeginCopyModelOptions

optionale Einstellungen für

Gibt zurück

ein Vorgang mit langer Ausführungsdauer (Poller), der schließlich die kopierten Modellinformationen oder einen Fehler erzeugt

deleteDocumentClassifier(string, OperationOptions)

Löscht einen Klassifizierer mit der angegebenen ID aus der Ressource des Clients, sofern vorhanden. Dieser Vorgang KANN NICHT wiederhergestellt werden.

Beispiel

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

Parameter

classifierId

string

die eindeutige ID des Klassifizierers, der aus der Ressource gelöscht werden soll

options
OperationOptions

optionale Einstellungen für die Anforderung

Gibt zurück

Promise<void>

deleteDocumentModel(string, DeleteDocumentModelOptions)

Löscht ein Modell mit der angegebenen ID aus der Ressource des Clients, sofern vorhanden. Dieser Vorgang KANN NICHT wiederhergestellt werden.

Beispiel

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

Parameter

modelId

string

die eindeutige ID des Modells, das aus der Ressource gelöscht werden soll

options
DeleteDocumentModelOptions

optionale Einstellungen für die Anforderung

Gibt zurück

Promise<void>

getCopyAuthorization(string, GetCopyAuthorizationOptions)

Erstellt eine Autorisierung zum Kopieren eines Modells in die Ressource, die mit der beginCopyModelTo -Methode verwendet wird.

Die CopyAuthorization gewährt einer anderen Cognitive Service-Ressource das Recht, ein Modell in der Ressource dieses Clients mit der Modell-ID und der optionalen Beschreibung zu erstellen, die in die Autorisierung codiert sind.

Beispiel

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

die eindeutige ID des Zielmodells (die ID, in die das Modell kopiert werden soll)

options
GetCopyAuthorizationOptions

optionale Einstellungen zum Erstellen der Kopierautorisierung

Gibt zurück

eine Kopierautorisierung, die die angegebene modelId codiert, und eine optionale Beschreibung

getDocumentClassifier(string, OperationOptions)

Ruft Informationen zu einem Klassifizierer (DocumentClassifierDetails) nach ID ab.

Beispiel

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

die eindeutige ID des abzufragenden Klassifizierers

options
OperationOptions

optionale Einstellungen für die Anforderung

Gibt zurück

Informationen zum Klassifizierer mit der angegebenen ID

getDocumentModel(string, GetModelOptions)

Ruft Informationen zu einem Modell (DocumentModelDetails) nach ID ab.

Diese Methode kann Informationen zu benutzerdefinierten und vordefinierten Modellen abrufen.

Breaking Change

In früheren Versionen der Formularerkennung REST-API und sdk konnte die getModel -Methode jedes Modell zurückgeben, auch eines, das aufgrund von Fehlern nicht erstellt werden konnte. Erstellen Sie in den neuen Dienstversionen nur erfolgreich erstellte Modelle (d. h. Modelle, getDocumentModellistDocumentModels die "bereit" für die Verwendung sind). Fehlerhafte Modelle werden jetzt über die "Operations"-APIs abgerufen. Weitere Informationen finden Sie unter getOperation und listOperations.

Beispiel

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

die eindeutige ID des abzufragenden Modells

options
GetModelOptions

optionale Einstellungen für die Anforderung

Gibt zurück

Informationen zum Modell mit der angegebenen ID

getOperation(string, GetOperationOptions)

Ruft Informationen zu einem Vorgang (OperationDetails) anhand seiner ID ab.

Vorgänge stellen Nicht-Analyseaufgaben dar, z. B. das Erstellen, Komponieren oder Kopieren eines Modells.

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

Parameter

operationId

string

die ID des abzufragenden Vorgangs

options
GetOperationOptions

optionale Einstellungen für die Anforderung

Gibt zurück

Promise<OperationDetails>

Informationen zum Vorgang mit der angegebenen ID

Beispiel

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

Rufen Sie grundlegende Informationen zur Ressource dieses Clients ab.

Beispiel

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

optionale Einstellungen für die Anforderung

Gibt zurück

Promise<ResourceDetails>

Grundlegende Informationen zur Ressource dieses Clients

listDocumentClassifiers(ListModelsOptions)

Auflisten von Details zu Klassifizierern in der Ressource. Dieser Vorgang unterstützt das Paging.

Beispiele

Asynchrone Iteration

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

Seite nach Seite

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

optionale Einstellungen für die Klassifizierungsanforderungen

Gibt zurück

eine asynchrone Iterable von Klassifiziererdetails, die Paging unterstützt

listDocumentModels(ListModelsOptions)

Listen Sie Zusammenfassungen von Modellen in der Ressource auf. Benutzerdefinierte sowie vordefinierte Modelle sind enthalten. Dieser Vorgang unterstützt das Paging.

Die Modellzusammenfassung (DocumentModelSummary) enthält nur die grundlegenden Informationen zum Modell und enthält keine Informationen zu den Dokumenttypen im Modell (z. B. feldschemas und Konfidenzwerte).

Verwenden Sie getDocumentModel, um auf die vollständigen Informationen zum Modell zuzugreifen.

Breaking Change

In früheren Versionen der Formularerkennung REST-API und sdk hat die listModels Methode alle Modelle zurückgegeben, auch die Modelle, die aufgrund von Fehlern nicht erstellt werden konnten. Erstellen Sie in den neuen Dienstversionen nur erfolgreich erstellte Modelle (d. h. Modelle, listDocumentModelsgetDocumentModel die "bereit" für die Verwendung sind). Fehlerhafte Modelle werden jetzt über die "Operations"-APIs abgerufen. Weitere Informationen finden Sie unter getOperation und listOperations.

Beispiele

Asynchrone Iteration

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

Seite nach Seite

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

optionale Einstellungen für die Modellanforderungen

Gibt zurück

eine asynchrone Iterable von Modellzusammenfassungen, die Paging unterstützt

listOperations(ListOperationsOptions)

Auflisten von Modellerstellungsvorgängen in der Ressource. Dadurch werden alle Vorgänge generiert, einschließlich Vorgängen, die nicht erfolgreich Modelle erstellt haben. Dieser Vorgang unterstützt das Paging.

Beispiele

Asynchrone Iteration

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

Seite nach Seite

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

optionale Einstellungen für die Vorgangsanforderungen

Gibt zurück

eine asynchrone Iterable von Vorgangsinformationsobjekten, die paging unterstützt