DocumentModelAdministrationClient class

Un client per interagire con le funzionalità di gestione dei modelli del servizio Riconoscimento modulo, ad esempio la creazione, la lettura, l'elenco, l'eliminazione e la copia dei modelli.

Esempi:

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

Chiave API (chiave di sottoscrizione)

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

Costruttori

DocumentModelAdministrationClient(string, KeyCredential, DocumentModelAdministrationClientOptions)

Creare un'istanza di DocumentModelAdministrationClient da un endpoint risorsa e una chiave API statica (KeyCredential),

Esempio:

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)

Creare un'istanza di DocumentModelAdministrationClient da un endpoint risorsa e un'identità TokenCredentialdi Azure .

Per altre informazioni sull'autenticazione con Azure Active Directory, vedere il @azure/identity pacchetto.

Esempio:

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

Metodi

beginBuildDocumentClassifier(string, DocumentClassifierDocumentTypeSources, BeginBuildDocumentClassifierOptions)

Creare un nuovo classificatore di documenti con l'ID classificatore e i tipi di documento specificati.

L'ID classificatore deve essere univoco tra i classificatori all'interno della risorsa.

I tipi di documento vengono assegnati come oggetto che esegue il mapping del nome del tipo di documento al set di dati di training per tale tipo di documento. Sono supportati due metodi di input dati di training:

  • azureBlobSource, che esegue il training di un classificatore usando i dati nel contenitore Archiviazione BLOB di Azure specificato.
  • azureBlobFileListSource, simile a azureBlobSource ma consente un controllo più granulare sui file inclusi nel set di dati di training usando un elenco di file in formato JSONL.

Il servizio Riconoscimento modulo legge il set di dati di training da un contenitore di archiviazione di Azure, dato come URL al contenitore con un token di firma di accesso condiviso che consente al back-end del servizio di comunicare con il contenitore. Almeno, sono necessarie le autorizzazioni "read" e "list". Inoltre, i dati nel contenitore specificato devono essere organizzati in base a una convenzione specifica, documentata nella documentazione del servizio per la creazione di classificatori di documenti personalizzati.

Esempio

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)

Creare un nuovo modello con un ID specificato da un'origine contenuto modello.

L'ID modello può essere costituito da qualsiasi testo, purché non inizi con "prebuilt-" (come questi modelli fanno riferimento a modelli predefiniti Riconoscimento modulo comuni a tutte le risorse) e fino a quando non esiste già all'interno della risorsa.

L'origine del contenuto descrive il meccanismo usato dal servizio per leggere i dati di training di input. Per altre informazioni, vedere il <xref:DocumentModelContentSource> tipo.

Esempio

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)

Creare un nuovo modello con un ID specificato da un set di documenti di input e campi etichettati.

L'ID modello può essere costituito da qualsiasi testo, purché non inizi con "prebuilt-" (come questi modelli fanno riferimento a modelli predefiniti Riconoscimento modulo comuni a tutte le risorse) e fino a quando non esiste già all'interno della risorsa.

Il servizio Riconoscimento modulo legge il set di dati di training da un contenitore di archiviazione di Azure, dato come URL al contenitore con un token di firma di accesso condiviso che consente al back-end del servizio di comunicare con il contenitore. Almeno, sono necessarie le autorizzazioni "read" e "list". Inoltre, i dati nel contenitore specificato devono essere organizzati in base a una determinata convenzione, documentata nella documentazione del servizio per la creazione di modelli personalizzati.

Esempio

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)

Crea un singolo modello composto da diversi sottomodelli preesistenti.

Il modello composto risultante combina i tipi di documento dei modelli di componente e inserisce un passaggio di classificazione nella pipeline di estrazione per determinare quale dei sottomodelli dei componenti è più appropriato per l'input specificato.

Esempio

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)

Copia un modello con l'ID specificato nella risorsa e nell'ID modello codificato da un'autorizzazione di copia specificata.

Vedere CopyAuthorization e getCopyAuthorization.

Esempio

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

Elimina un classificatore con l'ID specificato dalla risorsa del client, se presente. Questa operazione NON PUÒ essere ripristinata.

Esempio

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

Elimina un modello con l'ID specificato dalla risorsa del client, se presente. Questa operazione NON PUÒ essere ripristinata.

Esempio

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

Crea un'autorizzazione per copiare un modello nella risorsa, utilizzata con il beginCopyModelTo metodo .

Concede CopyAuthorization un'altra risorsa del servizio cognitivo il diritto di creare un modello nella risorsa del client con l'ID modello e la descrizione facoltativa codificata nell'autorizzazione.

Esempio

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

Recupera informazioni su un classificatore (DocumentClassifierDetails) in base all'ID.

Esempio

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)

Recupera informazioni su un modello (DocumentModelDetails) in base all'ID.

Questo metodo può recuperare informazioni su modelli personalizzati e predefiniti.

Modifica importante

Nelle versioni precedenti dell'API REST e dell'SDK Riconoscimento modulo il getModel metodo potrebbe restituire qualsiasi modello, anche uno che non è riuscito a creare a causa di errori. Nelle nuove versioni getDocumentModel del servizio e listDocumentModelsproducono solo modelli creati correttamente , ad esempio modelli "pronti" per l'uso. I modelli non riusciti vengono ora recuperati tramite le API "operations", vedere getOperation e listOperations.

Esempio

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

Recupera informazioni su un'operazione (OperationDetails) in base al relativo ID.

Le operazioni rappresentano attività non di analisi, ad esempio compilazione, composizione o copia di un modello.

getResourceDetails(GetResourceDetailsOptions)

Recuperare informazioni di base sulla risorsa del client.

Esempio

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)

Elencare i dettagli sui classificatori nella risorsa. Questa operazione supporta il paging.

Esempio

Iterazione asincrona

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

Per pagina

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

Elencare i riepiloghi dei modelli nella risorsa. Verranno inclusi modelli personalizzati e predefiniti. Questa operazione supporta il paging.

Il riepilogo del modello (DocumentModelSummary) include solo le informazioni di base sul modello e non include informazioni sui tipi di documento nel modello, ad esempio gli schemi dei campi e i valori di attendibilità.

Per accedere alle informazioni complete sul modello, usare getDocumentModel.

Modifica importante

Nelle versioni precedenti dell'API REST e dell'SDK Riconoscimento modulo, il listModels metodo restituirà tutti i modelli, anche quelli che non sono riusciti a creare a causa di errori. Nelle nuove versioni listDocumentModels del servizio e getDocumentModelproducono solo modelli creati correttamente , ad esempio modelli "pronti" per l'uso. I modelli non riusciti vengono ora recuperati tramite le API "operations", vedere getOperation e listOperations.

Esempio

Iterazione asincrona

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

Per pagina

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

Elencare le operazioni di creazione del modello nella risorsa. In questo modo verranno prodotte tutte le operazioni, incluse le operazioni che non sono riuscite a creare modelli correttamente. Questa operazione supporta il paging.

Esempio

Iterazione asincrona

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

Per pagina

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

Dettagli costruttore

DocumentModelAdministrationClient(string, KeyCredential, DocumentModelAdministrationClientOptions)

Creare un'istanza di DocumentModelAdministrationClient da un endpoint risorsa e una chiave API statica (KeyCredential),

Esempio:

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)

Parametri

endpoint

string

URL dell'endpoint di un'istanza di Servizi cognitivi di Azure

credential
KeyCredential

KeyCredential contenente la chiave di sottoscrizione dell'istanza di Servizi cognitivi

options
DocumentModelAdministrationClientOptions

impostazioni facoltative per la configurazione di tutti i metodi nel client

DocumentModelAdministrationClient(string, TokenCredential, DocumentModelAdministrationClientOptions)

Creare un'istanza di DocumentModelAdministrationClient da un endpoint risorsa e un'identità TokenCredentialdi Azure .

Per altre informazioni sull'autenticazione con Azure Active Directory, vedere il @azure/identity pacchetto.

Esempio:

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)

Parametri

endpoint

string

URL dell'endpoint di un'istanza di Servizi cognitivi di Azure

credential
TokenCredential

Istanza di TokenCredential dal @azure/identity pacchetto

options
DocumentModelAdministrationClientOptions

impostazioni facoltative per la configurazione di tutti i metodi nel client

Dettagli metodo

beginBuildDocumentClassifier(string, DocumentClassifierDocumentTypeSources, BeginBuildDocumentClassifierOptions)

Creare un nuovo classificatore di documenti con l'ID classificatore e i tipi di documento specificati.

L'ID classificatore deve essere univoco tra i classificatori all'interno della risorsa.

I tipi di documento vengono assegnati come oggetto che esegue il mapping del nome del tipo di documento al set di dati di training per tale tipo di documento. Sono supportati due metodi di input dati di training:

  • azureBlobSource, che esegue il training di un classificatore usando i dati nel contenitore Archiviazione BLOB di Azure specificato.
  • azureBlobFileListSource, simile a azureBlobSource ma consente un controllo più granulare sui file inclusi nel set di dati di training usando un elenco di file in formato JSONL.

Il servizio Riconoscimento modulo legge il set di dati di training da un contenitore di archiviazione di Azure, dato come URL al contenitore con un token di firma di accesso condiviso che consente al back-end del servizio di comunicare con il contenitore. Almeno, sono necessarie le autorizzazioni "read" e "list". Inoltre, i dati nel contenitore specificato devono essere organizzati in base a una convenzione specifica, documentata nella documentazione del servizio per la creazione di classificatori di documenti personalizzati.

Esempio

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>

Parametri

classifierId

string

ID univoco del classificatore da creare

docTypeSources
DocumentClassifierDocumentTypeSources

i tipi di documento da includere nel classificatore e nelle relative origini (una mappa dei nomi dei tipi di documento a ClassifierDocumentTypeDetails)

options
BeginBuildDocumentClassifierOptions

impostazioni facoltative per l'operazione di compilazione del classificatore

Restituisce

operazione a esecuzione prolungata (poller) che genererà i dettagli del classificatore creati o un errore

beginBuildDocumentModel(string, DocumentModelSource, DocumentModelBuildMode, BeginBuildDocumentModelOptions)

Creare un nuovo modello con un ID specificato da un'origine contenuto modello.

L'ID modello può essere costituito da qualsiasi testo, purché non inizi con "prebuilt-" (come questi modelli fanno riferimento a modelli predefiniti Riconoscimento modulo comuni a tutte le risorse) e fino a quando non esiste già all'interno della risorsa.

L'origine del contenuto descrive il meccanismo usato dal servizio per leggere i dati di training di input. Per altre informazioni, vedere il <xref:DocumentModelContentSource> tipo.

Esempio

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>

Parametri

modelId

string

ID univoco del modello da creare

contentSource
DocumentModelSource

origine contenuto che fornisce i dati di training per questo modello

buildMode

DocumentModelBuildMode

modalità da usare durante la compilazione del modello (vedere DocumentModelBuildMode)

options
BeginBuildDocumentModelOptions

impostazioni facoltative per l'operazione di compilazione del modello

Restituisce

un'operazione a esecuzione prolungata (poller) che genererà infine le informazioni del modello create o un errore

beginBuildDocumentModel(string, string, DocumentModelBuildMode, BeginBuildDocumentModelOptions)

Creare un nuovo modello con un ID specificato da un set di documenti di input e campi etichettati.

L'ID modello può essere costituito da qualsiasi testo, purché non inizi con "prebuilt-" (come questi modelli fanno riferimento a modelli predefiniti Riconoscimento modulo comuni a tutte le risorse) e fino a quando non esiste già all'interno della risorsa.

Il servizio Riconoscimento modulo legge il set di dati di training da un contenitore di archiviazione di Azure, dato come URL al contenitore con un token di firma di accesso condiviso che consente al back-end del servizio di comunicare con il contenitore. Almeno, sono necessarie le autorizzazioni "read" e "list". Inoltre, i dati nel contenitore specificato devono essere organizzati in base a una determinata convenzione, documentata nella documentazione del servizio per la creazione di modelli personalizzati.

Esempio

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>

Parametri

modelId

string

ID univoco del modello da creare

containerUrl

string

URL codificato con firma di accesso condiviso in un contenitore di archiviazione di Azure che contiene il set di dati di training

buildMode

DocumentModelBuildMode

modalità da usare durante la compilazione del modello (vedere DocumentModelBuildMode)

options
BeginBuildDocumentModelOptions

impostazioni facoltative per l'operazione di compilazione del modello

Restituisce

un'operazione a esecuzione prolungata (poller) che genererà infine le informazioni del modello create o un errore

beginComposeDocumentModel(string, Iterable<string>, BeginComposeDocumentModelOptions)

Crea un singolo modello composto da diversi sottomodelli preesistenti.

Il modello composto risultante combina i tipi di documento dei modelli di componente e inserisce un passaggio di classificazione nella pipeline di estrazione per determinare quale dei sottomodelli dei componenti è più appropriato per l'input specificato.

Esempio

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>

Parametri

modelId

string

ID univoco del modello da creare

componentModelIds

Iterable<string>

iterabile di stringhe che rappresentano gli ID modello univoci dei modelli da comporre

options
BeginComposeDocumentModelOptions

impostazioni facoltative per la creazione di modelli

Restituisce

un'operazione a esecuzione prolungata (poller) che genererà infine le informazioni del modello create o un errore

beginCopyModelTo(string, CopyAuthorization, BeginCopyModelOptions)

Copia un modello con l'ID specificato nella risorsa e nell'ID modello codificato da un'autorizzazione di copia specificata.

Vedere CopyAuthorization e getCopyAuthorization.

Esempio

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

Parametri

sourceModelId

string

ID univoco del modello di origine copiato

authorization
CopyAuthorization

autorizzazione per copiare il modello, creato usando getCopyAuthorization

options
BeginCopyModelOptions

impostazioni facoltative per

Restituisce

operazione a esecuzione prolungata (poller) che genererà infine le informazioni del modello copiate o un errore

deleteDocumentClassifier(string, OperationOptions)

Elimina un classificatore con l'ID specificato dalla risorsa del client, se presente. Questa operazione NON PUÒ essere ripristinata.

Esempio

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

Parametri

classifierId

string

ID univoco del classificatore da eliminare dalla risorsa

options
OperationOptions

impostazioni facoltative per la richiesta

Restituisce

Promise<void>

deleteDocumentModel(string, DeleteDocumentModelOptions)

Elimina un modello con l'ID specificato dalla risorsa del client, se presente. Questa operazione NON PUÒ essere ripristinata.

Esempio

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

Parametri

modelId

string

ID univoco del modello da eliminare dalla risorsa

options
DeleteDocumentModelOptions

impostazioni facoltative per la richiesta

Restituisce

Promise<void>

getCopyAuthorization(string, GetCopyAuthorizationOptions)

Crea un'autorizzazione per copiare un modello nella risorsa, utilizzata con il beginCopyModelTo metodo .

Concede CopyAuthorization un'altra risorsa del servizio cognitivo il diritto di creare un modello nella risorsa del client con l'ID modello e la descrizione facoltativa codificata nell'autorizzazione.

Esempio

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

Parametri

destinationModelId

string

ID univoco del modello di destinazione (ID in cui copiare il modello)

options
GetCopyAuthorizationOptions

impostazioni facoltative per la creazione dell'autorizzazione di copia

Restituisce

autorizzazione di copia che codifica il modelId specificato e la descrizione facoltativa

getDocumentClassifier(string, OperationOptions)

Recupera informazioni su un classificatore (DocumentClassifierDetails) in base all'ID.

Esempio

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>

Parametri

classifierId

string

ID univoco del classificatore da eseguire in query

options
OperationOptions

impostazioni facoltative per la richiesta

Restituisce

informazioni sul classificatore con l'ID specificato

getDocumentModel(string, GetModelOptions)

Recupera informazioni su un modello (DocumentModelDetails) in base all'ID.

Questo metodo può recuperare informazioni su modelli personalizzati e predefiniti.

Modifica importante

Nelle versioni precedenti dell'API REST e dell'SDK Riconoscimento modulo il getModel metodo potrebbe restituire qualsiasi modello, anche uno che non è riuscito a creare a causa di errori. Nelle nuove versioni getDocumentModel del servizio e listDocumentModelsproducono solo modelli creati correttamente , ad esempio modelli "pronti" per l'uso. I modelli non riusciti vengono ora recuperati tramite le API "operations", vedere getOperation e listOperations.

Esempio

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

Parametri

modelId

string

ID univoco del modello da eseguire query

options
GetModelOptions

impostazioni facoltative per la richiesta

Restituisce

informazioni sul modello con l'ID specificato

getOperation(string, GetOperationOptions)

Recupera informazioni su un'operazione (OperationDetails) in base al relativo ID.

Le operazioni rappresentano attività non di analisi, ad esempio compilazione, composizione o copia di un modello.

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

Parametri

operationId

string

ID dell'operazione da eseguire query

options
GetOperationOptions

impostazioni facoltative per la richiesta

Restituisce

Promise<OperationDetails>

informazioni sull'operazione con l'ID specificato

Esempio

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

Recuperare informazioni di base sulla risorsa del client.

Esempio

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>

Parametri

options
GetResourceDetailsOptions

impostazioni facoltative per la richiesta

Restituisce

Promise<ResourceDetails>

informazioni di base sulla risorsa del client

listDocumentClassifiers(ListModelsOptions)

Elencare i dettagli sui classificatori nella risorsa. Questa operazione supporta il paging.

Esempio

Iterazione asincrona

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

Per pagina

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

Parametri

options
ListModelsOptions

impostazioni facoltative per le richieste del classificatore

Restituisce

un iterabile asincrono dei dettagli del classificatore che supporta il paging

listDocumentModels(ListModelsOptions)

Elencare i riepiloghi dei modelli nella risorsa. Verranno inclusi modelli personalizzati e predefiniti. Questa operazione supporta il paging.

Il riepilogo del modello (DocumentModelSummary) include solo le informazioni di base sul modello e non include informazioni sui tipi di documento nel modello, ad esempio gli schemi dei campi e i valori di attendibilità.

Per accedere alle informazioni complete sul modello, usare getDocumentModel.

Modifica importante

Nelle versioni precedenti dell'API REST e dell'SDK Riconoscimento modulo, il listModels metodo restituirà tutti i modelli, anche quelli che non sono riusciti a creare a causa di errori. Nelle nuove versioni listDocumentModels del servizio e getDocumentModelproducono solo modelli creati correttamente , ad esempio modelli "pronti" per l'uso. I modelli non riusciti vengono ora recuperati tramite le API "operations", vedere getOperation e listOperations.

Esempio

Iterazione asincrona

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

Per pagina

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

Parametri

options
ListModelsOptions

impostazioni facoltative per le richieste di modello

Restituisce

un iterabile asincrono dei riepiloghi del modello che supporta il paging

listOperations(ListOperationsOptions)

Elencare le operazioni di creazione del modello nella risorsa. In questo modo verranno prodotte tutte le operazioni, incluse le operazioni che non sono riuscite a creare modelli correttamente. Questa operazione supporta il paging.

Esempio

Iterazione asincrona

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

Per pagina

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

Parametri

options
ListOperationsOptions

impostazioni facoltative per le richieste di operazione

Restituisce

un iterabile iterabile degli oggetti di informazioni sulle operazioni che supportano il paging