DocumentModelAdministrationClient class
En klient för att interagera med tjänsten Formigenkänningstjänsts modellhanteringsfunktioner, till exempel att skapa, läsa, lista, ta bort och kopiera modeller.
Exempel:
Azure Active Directory
import { DefaultAzureCredential } from "@azure/identity";
import { DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
const credential = new DefaultAzureCredential();
const client = new DocumentModelAdministrationClient(
"https://<resource name>.cognitiveservices.azure.com",
credential,
);
API-nyckel (prenumerationsnyckel)
import { AzureKeyCredential, DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
const credential = new AzureKeyCredential("<API key>");
const client = new DocumentModelAdministrationClient(
"https://<resource name>.cognitiveservices.azure.com",
credential,
);
Konstruktorer
Document |
Skapa en DocumentModelAdministrationClient-instans från en resursslutpunkt och en statisk API-nyckel ( Exempel:
|
Document |
Skapa en DocumentModelAdministrationClient-instans från en resursslutpunkt och en Azure Identity- Mer information om autentisering med Azure Active Directory finns i Exempel:
|
Metoder
begin |
Skapa en ny dokumentklassificerare med angivet klassificerar-ID och dokumenttyper. Klassificerarens ID måste vara unikt bland klassificerare i resursen. Dokumenttyperna anges som ett objekt som mappar namnet på dokumenttypen till träningsdatauppsättningen för den dokumenttypen. Två metoder för inmatning av träningsdata stöds:
Tjänsten Formigenkänning läser träningsdatauppsättningen från en Azure Storage-container, som anges som en URL till containern med en SAS-token som gör att tjänstserverdelen kan kommunicera med containern. Behörigheterna "read" och "list" krävs som minst. Dessutom måste data i den angivna containern ordnas enligt en viss konvention, som dokumenteras i tjänstens dokumentation för att skapa anpassade dokumentklassificerare. Exempel
|
begin |
Skapa en ny modell med ett givet ID från en modellinnehållskälla. Modell-ID:t kan bestå av valfri text, så länge det inte börjar med "prebuilt-" (eftersom dessa modeller refererar till fördefinierade formigenkänningsmodeller som är gemensamma för alla resurser) och så länge det inte redan finns i resursen. Innehållskällan beskriver den mekanism som tjänsten använder för att läsa träningsdata för indata. Mer information finns i <xref:DocumentModelContentSource> typ. Exempel
|
begin |
Skapa en ny modell med ett givet ID från en uppsättning indatadokument och märkta fält. Modell-ID:t kan bestå av valfri text, så länge det inte börjar med "prebuilt-" (eftersom dessa modeller refererar till fördefinierade formigenkänningsmodeller som är gemensamma för alla resurser) och så länge det inte redan finns i resursen. Tjänsten Formigenkänning läser träningsdatauppsättningen från en Azure Storage-container, som anges som en URL till containern med en SAS-token som gör att tjänstserverdelen kan kommunicera med containern. Behörigheterna "read" och "list" krävs som minst. Dessutom måste data i den angivna containern ordnas enligt en viss konvention, som dokumenteras i tjänstens dokumentation för att skapa anpassade modeller. Exempel
|
begin |
Skapar en enskild sammansatt modell från flera befintliga undermodeller. Den resulterande sammansatta modellen kombinerar dokumenttyperna för sina komponentmodeller och infogar ett klassificeringssteg i extraheringspipelinen för att avgöra vilken av dess komponentundermodeller som är lämpligast för de angivna indata. Exempel
|
begin |
Kopierar en modell med det angivna ID:t till resurs- och modell-ID:t som kodas av en viss kopieringsauktorisering. Se CopyAuthorization och getCopyAuthorization. Exempel
|
delete |
Tar bort en klassificerare med det angivna ID:t från klientens resurs, om den finns. Det går inte att återställa den här åtgärden. Exempel
|
delete |
Tar bort en modell med det angivna ID:t från klientens resurs, om den finns. Det går inte att återställa den här åtgärden. Exempel
|
get |
Skapar en auktorisering för att kopiera en modell till resursen som används med metoden
Exempel
|
get |
Hämtar information om en klassificerare (DocumentClassifierDetails) efter ID. Exempel
|
get |
Hämtar information om en modell (DocumentModelDetails) efter ID. Den här metoden kan hämta information om anpassade och fördefinierade modeller. icke-bakåtkompatibel ändringI tidigare versioner av REST API för formulärigenkänning och SDK kan metoden Exempel
|
get |
Hämtar information om en åtgärd ( Åtgärder representerar icke-analysaktiviteter, till exempel att skapa, skapa eller kopiera en modell. |
get |
Hämta grundläggande information om klientens resurs. Exempel
|
list |
Visa information om klassificerare i resursen. Den här åtgärden stöder växling. ExempelAsynkron iteration
|
list |
Lista sammanfattningar av modeller i resursen. Anpassade och fördefinierade modeller kommer att ingå. Den här åtgärden stöder växling. Modellsammanfattningen (DocumentModelSummary) innehåller endast grundläggande information om modellen och innehåller inte information om dokumenttyperna i modellen (till exempel fältscheman och konfidensvärden). Om du vill komma åt fullständig information om modellen använder du getDocumentModel. icke-bakåtkompatibel ändringI tidigare versioner av REST API för formulärigenkänning och SDK returnerar metoden ExempelAsynkron iteration
|
list |
Lista modellskapandeåtgärder i resursen. Detta skapar alla åtgärder, inklusive åtgärder som inte kunde skapa modeller. Den här åtgärden stöder växling. ExempelAsynkron iteration
|
Konstruktorinformation
DocumentModelAdministrationClient(string, KeyCredential, DocumentModelAdministrationClientOptions)
Skapa en DocumentModelAdministrationClient-instans från en resursslutpunkt och en statisk API-nyckel (KeyCredential
),
Exempel:
import { AzureKeyCredential, DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
const credential = new AzureKeyCredential("<API key>");
const client = new DocumentModelAdministrationClient(
"https://<resource name>.cognitiveservices.azure.com",
credential,
);
new DocumentModelAdministrationClient(endpoint: string, credential: KeyCredential, options?: DocumentModelAdministrationClientOptions)
Parametrar
- endpoint
-
string
slutpunkts-URL:en för en Azure Cognitive Services-instans
- credential
- KeyCredential
en KeyCredential som innehåller prenumerationsnyckeln för Cognitive Services-instansen
valfria inställningar för att konfigurera alla metoder i klienten
DocumentModelAdministrationClient(string, TokenCredential, DocumentModelAdministrationClientOptions)
Skapa en DocumentModelAdministrationClient-instans från en resursslutpunkt och en Azure Identity-TokenCredential
.
Mer information om autentisering med Azure Active Directory finns i @azure/identity
-paketet.
Exempel:
import { DefaultAzureCredential } from "@azure/identity";
import { DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
const credential = new DefaultAzureCredential();
const client = new DocumentModelAdministrationClient(
"https://<resource name>.cognitiveservices.azure.com",
credential,
);
new DocumentModelAdministrationClient(endpoint: string, credential: TokenCredential, options?: DocumentModelAdministrationClientOptions)
Parametrar
- endpoint
-
string
slutpunkts-URL:en för en Azure Cognitive Services-instans
- credential
- TokenCredential
en TokenCredential-instans från @azure/identity
-paketet
valfria inställningar för att konfigurera alla metoder i klienten
Metodinformation
beginBuildDocumentClassifier(string, DocumentClassifierDocumentTypeSources, BeginBuildDocumentClassifierOptions)
Skapa en ny dokumentklassificerare med angivet klassificerar-ID och dokumenttyper.
Klassificerarens ID måste vara unikt bland klassificerare i resursen.
Dokumenttyperna anges som ett objekt som mappar namnet på dokumenttypen till träningsdatauppsättningen för den dokumenttypen. Två metoder för inmatning av träningsdata stöds:
-
azureBlobSource
, som tränar en klassificerare med hjälp av data i den angivna Azure Blob Storage-containern. -
azureBlobFileListSource
, som liknarazureBlobSource
men ger mer detaljerad kontroll över de filer som ingår i träningsdatauppsättningen med hjälp av en JSONL-formaterad fillista.
Tjänsten Formigenkänning läser träningsdatauppsättningen från en Azure Storage-container, som anges som en URL till containern med en SAS-token som gör att tjänstserverdelen kan kommunicera med containern. Behörigheterna "read" och "list" krävs som minst. Dessutom måste data i den angivna containern ordnas enligt en viss konvention, som dokumenteras i tjänstens dokumentation för att skapa anpassade dokumentklassificerare.
Exempel
import { DefaultAzureCredential } from "@azure/identity";
import { DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
const credential = new DefaultAzureCredential();
const client = new DocumentModelAdministrationClient(
"https://<resource name>.cognitiveservices.azure.com",
credential,
);
const newClassifiedId = "aNewClassifier";
const containerUrl1 = "<training data container SAS URL 1>";
const containerUrl2 = "<training data container SAS URL 2>";
const poller = await client.beginBuildDocumentClassifier(
newClassifiedId,
{
// 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>
Parametrar
- classifierId
-
string
klassificerarens unika ID som ska skapas
- docTypeSources
- DocumentClassifierDocumentTypeSources
de dokumenttyper som ska ingå i klassificeraren och deras källor (en karta över dokumenttypsnamn till ClassifierDocumentTypeDetails
)
valfria inställningar för klassificerarens byggåtgärd
Returer
Promise<DocumentClassifierPoller>
en tidskrävande åtgärd (poller) som så småningom skapar information om den skapade klassificeraren eller ett fel
beginBuildDocumentModel(string, DocumentModelSource, DocumentModelBuildMode, BeginBuildDocumentModelOptions)
Skapa en ny modell med ett givet ID från en modellinnehållskälla.
Modell-ID:t kan bestå av valfri text, så länge det inte börjar med "prebuilt-" (eftersom dessa modeller refererar till fördefinierade formigenkänningsmodeller som är gemensamma för alla resurser) och så länge det inte redan finns i resursen.
Innehållskällan beskriver den mekanism som tjänsten använder för att läsa träningsdata för indata. Mer information finns i <xref:DocumentModelContentSource> typ.
Exempel
import { DefaultAzureCredential } from "@azure/identity";
import { DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
const credential = new DefaultAzureCredential();
const client = new DocumentModelAdministrationClient(
"https://<resource name>.cognitiveservices.azure.com",
credential,
);
const containerSasUrl = "<SAS url to the blob container storing training documents>";
// You must provide the model ID. It can be any text that does not start with "prebuilt-".
// For example, you could provide a randomly generated GUID using the "uuid" package.
// The second parameter is the SAS-encoded URL to an Azure Storage container with the training documents.
// The third parameter is the build mode: one of "template" (the only mode prior to 4.0.0-beta.3) or "neural".
// See https://aka.ms/azsdk/formrecognizer/buildmode for more information about build modes.
const poller = await client.beginBuildDocumentModel(
"<model ID>",
{ azureBlobSource: { containerUrl: containerSasUrl } },
"template",
{
// The model description is optional and can be any text.
description: "This is my new model!",
onProgress: ({ status }) => {
console.log(`operation status: ${status}`);
},
},
);
const model = await poller.pollUntilDone();
console.log(`Model ID: ${model.modelId}`);
console.log(`Description: ${model.description}`);
console.log(`Created: ${model.createdOn}`);
// A model may contain several document types, which describe the possible object structures of fields extracted using
// this model
console.log("Document Types:");
for (const [docType, { description, fieldSchema: schema }] of Object.entries(
model.docTypes ?? {},
)) {
console.log(`- Name: "${docType}"`);
console.log(` Description: "${description}"`);
// For simplicity, this example will only show top-level field names
console.log(" Fields:");
for (const [fieldName, fieldSchema] of Object.entries(schema)) {
console.log(` - "${fieldName}" (${fieldSchema.type})`);
console.log(` ${fieldSchema.description ?? "<no description>"}`);
}
}
function beginBuildDocumentModel(modelId: string, contentSource: DocumentModelSource, buildMode: DocumentModelBuildMode, options?: BeginBuildDocumentModelOptions): Promise<DocumentModelPoller>
Parametrar
- modelId
-
string
det unika ID för modellen som ska skapas
- contentSource
- DocumentModelSource
en innehållskälla som tillhandahåller träningsdata för den här modellen
- buildMode
-
DocumentModelBuildMode
läget som ska användas när modellen skapas (se DocumentModelBuildMode
)
- options
- BeginBuildDocumentModelOptions
valfria inställningar för modellbyggåtgärden
Returer
Promise<DocumentModelPoller>
en tidskrävande åtgärd (poller) som så småningom skapar den skapade modellinformationen eller ett fel
beginBuildDocumentModel(string, string, DocumentModelBuildMode, BeginBuildDocumentModelOptions)
Skapa en ny modell med ett givet ID från en uppsättning indatadokument och märkta fält.
Modell-ID:t kan bestå av valfri text, så länge det inte börjar med "prebuilt-" (eftersom dessa modeller refererar till fördefinierade formigenkänningsmodeller som är gemensamma för alla resurser) och så länge det inte redan finns i resursen.
Tjänsten Formigenkänning läser träningsdatauppsättningen från en Azure Storage-container, som anges som en URL till containern med en SAS-token som gör att tjänstserverdelen kan kommunicera med containern. Behörigheterna "read" och "list" krävs som minst. Dessutom måste data i den angivna containern ordnas enligt en viss konvention, som dokumenteras i tjänstens dokumentation för att skapa anpassade modeller.
Exempel
import { DefaultAzureCredential } from "@azure/identity";
import { DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
const credential = new DefaultAzureCredential();
const client = new DocumentModelAdministrationClient(
"https://<resource name>.cognitiveservices.azure.com",
credential,
);
const containerSasUrl = "<SAS url to the blob container storing training documents>";
// You must provide the model ID. It can be any text that does not start with "prebuilt-".
// For example, you could provide a randomly generated GUID using the "uuid" package.
// The second parameter is the SAS-encoded URL to an Azure Storage container with the training documents.
// The third parameter is the build mode: one of "template" (the only mode prior to 4.0.0-beta.3) or "neural".
// See https://aka.ms/azsdk/formrecognizer/buildmode for more information about build modes.
const poller = await client.beginBuildDocumentModel("<model ID>", containerSasUrl, "template", {
// The model description is optional and can be any text.
description: "This is my new model!",
onProgress: ({ status }) => {
console.log(`operation status: ${status}`);
},
});
const model = await poller.pollUntilDone();
console.log(`Model ID: ${model.modelId}`);
console.log(`Description: ${model.description}`);
console.log(`Created: ${model.createdOn}`);
// A model may contain several document types, which describe the possible object structures of fields extracted using
// this model
console.log("Document Types:");
for (const [docType, { description, fieldSchema: schema }] of Object.entries(
model.docTypes ?? {},
)) {
console.log(`- Name: "${docType}"`);
console.log(` Description: "${description}"`);
// For simplicity, this example will only show top-level field names
console.log(" Fields:");
for (const [fieldName, fieldSchema] of Object.entries(schema)) {
console.log(` - "${fieldName}" (${fieldSchema.type})`);
console.log(` ${fieldSchema.description ?? "<no description>"}`);
}
}
function beginBuildDocumentModel(modelId: string, containerUrl: string, buildMode: DocumentModelBuildMode, options?: BeginBuildDocumentModelOptions): Promise<DocumentModelPoller>
Parametrar
- modelId
-
string
det unika ID för modellen som ska skapas
- containerUrl
-
string
SAS-kodad URL till en Azure Storage-container som innehåller träningsdatauppsättningen
- buildMode
-
DocumentModelBuildMode
läget som ska användas när modellen skapas (se DocumentModelBuildMode
)
- options
- BeginBuildDocumentModelOptions
valfria inställningar för modellbyggåtgärden
Returer
Promise<DocumentModelPoller>
en tidskrävande åtgärd (poller) som så småningom skapar den skapade modellinformationen eller ett fel
beginComposeDocumentModel(string, Iterable<string>, BeginComposeDocumentModelOptions)
Skapar en enskild sammansatt modell från flera befintliga undermodeller.
Den resulterande sammansatta modellen kombinerar dokumenttyperna för sina komponentmodeller och infogar ett klassificeringssteg i extraheringspipelinen för att avgöra vilken av dess komponentundermodeller som är lämpligast för de angivna indata.
Exempel
import { DefaultAzureCredential } from "@azure/identity";
import { DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
const credential = new DefaultAzureCredential();
const client = new DocumentModelAdministrationClient(
"https://<resource name>.cognitiveservices.azure.com",
credential,
);
const composeModelId = "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(composeModelId, 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>
Parametrar
- modelId
-
string
det unika ID för modellen som ska skapas
- componentModelIds
-
Iterable<string>
en iterabel med strängar som representerar de unika modell-ID:t för de modeller som ska skrivas
- options
- BeginComposeDocumentModelOptions
valfria inställningar för att skapa modell
Returer
Promise<DocumentModelPoller>
en tidskrävande åtgärd (poller) som så småningom skapar den skapade modellinformationen eller ett fel
beginCopyModelTo(string, CopyAuthorization, BeginCopyModelOptions)
Kopierar en modell med det angivna ID:t till resurs- och modell-ID:t som kodas av en viss kopieringsauktorisering.
Se CopyAuthorization och getCopyAuthorization.
Exempel
import { DefaultAzureCredential } from "@azure/identity";
import { DocumentModelAdministrationClient, AzureKeyCredential } from "@azure/ai-form-recognizer";
const credential = new DefaultAzureCredential();
const client = new DocumentModelAdministrationClient(
"https://<resource name>.cognitiveservices.azure.com",
credential,
);
// 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
// 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);
const poller = await sourceClient.beginCopyModelTo("<source model ID>", copyAuthorization);
// 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>
Parametrar
- sourceModelId
-
string
det unika ID:t för källmodellen som ska kopieras
- authorization
- CopyAuthorization
en auktorisering för att kopiera modellen som skapats med hjälp av getCopyAuthorization
- options
- BeginCopyModelOptions
valfria inställningar för
Returer
Promise<DocumentModelPoller>
en tidskrävande åtgärd (poller) som så småningom skapar den kopierade modellinformationen eller ett fel
deleteDocumentClassifier(string, OperationOptions)
Tar bort en klassificerare med det angivna ID:t från klientens resurs, om den finns. Det går inte att återställa den här åtgärden.
Exempel
import { DefaultAzureCredential } from "@azure/identity";
import { DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
const credential = new DefaultAzureCredential();
const client = new DocumentModelAdministrationClient(
"https://<resource name>.cognitiveservices.azure.com",
credential,
);
await client.deleteDocumentClassifier("<classifier ID to delete>");
function deleteDocumentClassifier(classifierId: string, options?: OperationOptions): Promise<void>
Parametrar
- classifierId
-
string
klassificerarens unika ID som ska tas bort från resursen
- options
- OperationOptions
valfria inställningar för begäran
Returer
Promise<void>
deleteDocumentModel(string, DeleteDocumentModelOptions)
Tar bort en modell med det angivna ID:t från klientens resurs, om den finns. Det går inte att återställa den här åtgärden.
Exempel
import { DefaultAzureCredential } from "@azure/identity";
import { DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
const credential = new DefaultAzureCredential();
const client = new DocumentModelAdministrationClient(
"https://<resource name>.cognitiveservices.azure.com",
credential,
);
await client.deleteDocumentModel("<model ID to delete>");
function deleteDocumentModel(modelId: string, options?: DeleteDocumentModelOptions): Promise<void>
Parametrar
- modelId
-
string
det unika ID för modellen som ska tas bort från resursen
- options
- DeleteDocumentModelOptions
valfria inställningar för begäran
Returer
Promise<void>
getCopyAuthorization(string, GetCopyAuthorizationOptions)
Skapar en auktorisering för att kopiera en modell till resursen som används med metoden beginCopyModelTo
.
CopyAuthorization
ger en annan kognitiv tjänstresurs rätt att skapa en modell i klientens resurs med modell-ID och valfri beskrivning som kodas i auktoriseringen.
Exempel
import { DefaultAzureCredential } from "@azure/identity";
import { DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
const credential = new DefaultAzureCredential();
const client = new DocumentModelAdministrationClient(
"https://<resource name>.cognitiveservices.azure.com",
credential,
);
// 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>
Parametrar
- destinationModelId
-
string
målmodellens unika ID (det ID som modellen ska kopieras till)
- options
- GetCopyAuthorizationOptions
valfria inställningar för att skapa kopieringsauktoriseringen
Returer
Promise<CopyAuthorization>
en kopieringsauktorisering som kodar det angivna modelId:et och valfri beskrivning
getDocumentClassifier(string, OperationOptions)
Hämtar information om en klassificerare (DocumentClassifierDetails) efter ID.
Exempel
import { DefaultAzureCredential } from "@azure/identity";
import { DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
const credential = new DefaultAzureCredential();
const client = new DocumentModelAdministrationClient(
"https://<resource name>.cognitiveservices.azure.com",
credential,
);
const foundClassifier = "<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(foundClassifier);
// 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>
Parametrar
- classifierId
-
string
klassificerarens unika ID för frågan
- options
- OperationOptions
valfria inställningar för begäran
Returer
Promise<DocumentClassifierDetails>
information om klassificeraren med angivet ID
getDocumentModel(string, GetModelOptions)
Hämtar information om en modell (DocumentModelDetails) efter ID.
Den här metoden kan hämta information om anpassade och fördefinierade modeller.
icke-bakåtkompatibel ändring
I tidigare versioner av REST API för formulärigenkänning och SDK kan metoden getModel
returnera vilken modell som helst, även en som inte kunde skapas på grund av fel. I de nya tjänstversionerna getDocumentModel
och listDocumentModels
endast skapa modeller som har skapats (dvs. modeller som är "redo" för användning). Misslyckade modeller hämtas nu via API:er för "åtgärder", se getOperation och listOperations.
Exempel
import { DefaultAzureCredential } from "@azure/identity";
import { DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
const credential = new DefaultAzureCredential();
const client = new DocumentModelAdministrationClient(
"https://<resource name>.cognitiveservices.azure.com",
credential,
);
// The ID of the prebuilt business card model
const prebuiltModelId = "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: businessCardDescription,
// 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(prebuiltModelId);
function getDocumentModel(modelId: string, options?: GetModelOptions): Promise<DocumentModelDetails>
Parametrar
- modelId
-
string
modellens unika ID att köra frågor mot
- options
- GetModelOptions
valfria inställningar för begäran
Returer
Promise<DocumentModelDetails>
information om modellen med det angivna ID:t
getOperation(string, GetOperationOptions)
Hämtar information om en åtgärd (OperationDetails
) med dess ID.
Åtgärder representerar icke-analysaktiviteter, till exempel att skapa, skapa eller kopiera en modell.
function getOperation(operationId: string, options?: GetOperationOptions): Promise<OperationDetails>
Parametrar
- operationId
-
string
ID:t för åtgärden som ska köras mot
- options
- GetOperationOptions
valfria inställningar för begäran
Returer
Promise<OperationDetails>
information om åtgärden med det angivna ID:t
Exempel
import { DefaultAzureCredential } from "@azure/identity";
import { DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
const credential = new DefaultAzureCredential();
const client = new DocumentModelAdministrationClient(
"https://<resource name>.cognitiveservices.azure.com",
credential,
);
// The ID of the operation, which should be a GUID
const findOperationId = "<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(findOperationId);
getResourceDetails(GetResourceDetailsOptions)
Hämta grundläggande information om klientens resurs.
Exempel
import { DefaultAzureCredential } from "@azure/identity";
import { DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
const credential = new DefaultAzureCredential();
const client = new DocumentModelAdministrationClient(
"https://<resource name>.cognitiveservices.azure.com",
credential,
);
const {
// Information about the custom models in the current resource
customDocumentModels: {
// 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>
Parametrar
- options
- GetResourceDetailsOptions
valfria inställningar för begäran
Returer
Promise<ResourceDetails>
grundläggande information om klientens resurs
listDocumentClassifiers(ListModelsOptions)
Visa information om klassificerare i resursen. Den här åtgärden stöder växling.
Exempel
Asynkron iteration
import { DefaultAzureCredential } from "@azure/identity";
import { DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
const credential = new DefaultAzureCredential();
const client = new DocumentModelAdministrationClient(
"https://<resource name>.cognitiveservices.azure.com",
credential,
);
for await (const details of client.listDocumentClassifiers()) {
const {
classifierId, // The classifier's unique ID
description, // a textual description of the classifier, if provided during creation
docTypes, // information about the document types in the classifier and their corresponding traning data
} = details;
}
// The listDocumentClassifiers method is paged, and you can iterate by page using the `byPage` method.
const pages = client.listDocumentClassifiers().byPage();
for await (const page of pages) {
// Each page is an array of classifiers and can be iterated synchronously
for (const details of page) {
const {
classifierId, // The classifier's unique ID
description, // a textual description of the classifier, if provided during creation
docTypes, // information about the document types in the classifier and their corresponding traning data
} = details;
}
}
function listDocumentClassifiers(options?: ListModelsOptions): PagedAsyncIterableIterator<DocumentClassifierDetails, DocumentClassifierDetails[], PageSettings>
Parametrar
- options
- ListModelsOptions
valfria inställningar för klassificeringsbegäranden
Returer
en asynkron iterbar klassificeringsinformation som stöder växling
listDocumentModels(ListModelsOptions)
Lista sammanfattningar av modeller i resursen. Anpassade och fördefinierade modeller kommer att ingå. Den här åtgärden stöder växling.
Modellsammanfattningen (DocumentModelSummary) innehåller endast grundläggande information om modellen och innehåller inte information om dokumenttyperna i modellen (till exempel fältscheman och konfidensvärden).
Om du vill komma åt fullständig information om modellen använder du getDocumentModel.
icke-bakåtkompatibel ändring
I tidigare versioner av REST API för formulärigenkänning och SDK returnerar metoden listModels
alla modeller, även de som inte kunde skapas på grund av fel. I de nya tjänstversionerna listDocumentModels
och getDocumentModel
endast skapa modeller som har skapats (dvs. modeller som är "redo" för användning). Misslyckade modeller hämtas nu via API:er för "åtgärder", se getOperation och listOperations.
Exempel
Asynkron iteration
import { DefaultAzureCredential } from "@azure/identity";
import { DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
const credential = new DefaultAzureCredential();
const client = new DocumentModelAdministrationClient(
"https://<resource name>.cognitiveservices.azure.com",
credential,
);
// Iterate over all models in the current resource
for await (const summary of client.listDocumentModels()) {
const {
modelId, // The model's unique ID
description, // a textual description of the model, if provided during model creation
} = summary;
// You can get the full model info using `getDocumentModel`
const model = await client.getDocumentModel(modelId);
}
// The listDocumentModels method is paged, and you can iterate by page using the `byPage` method.
const pages = client.listDocumentModels().byPage();
for await (const page of pages) {
// Each page is an array of models and can be iterated synchronously
for (const summary 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>
Parametrar
- options
- ListModelsOptions
valfria inställningar för modellbegäranden
Returer
en asynkron iterbar modellsammanfattning som stöder växling
listOperations(ListOperationsOptions)
Lista modellskapandeåtgärder i resursen. Detta skapar alla åtgärder, inklusive åtgärder som inte kunde skapa modeller. Den här åtgärden stöder växling.
Exempel
Asynkron iteration
import { DefaultAzureCredential } from "@azure/identity";
import { DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
const credential = new DefaultAzureCredential();
const client = new DocumentModelAdministrationClient(
"https://<resource name>.cognitiveservices.azure.com",
credential,
);
for await (const operation of client.listOperations()) {
const {
operationId, // the operation's GUID
status, // the operation status, one of "notStarted", "running", "succeeded", "failed", or "canceled"
percentCompleted, // the progress of the operation, from 0 to 100
} = operation;
}
// The listOperations method is paged, and you can iterate by page using the `byPage` method.
const pages = client.listOperations().byPage();
for await (const page of pages) {
// Each page is an array of operation info objects and can be iterated synchronously
for (const operation of page) {
const {
operationId, // the operation's GUID
status, // the operation status, one of "notStarted", "running", "succeeded", "failed", or "canceled"
percentCompleted, // the progress of the operation, from 0 to 100
} = operation;
}
}
function listOperations(options?: ListOperationsOptions): PagedAsyncIterableIterator<OperationSummary, OperationSummary[], PageSettings>
Parametrar
- options
- ListOperationsOptions
valfria inställningar för åtgärdsbegäranden
Returer
en asynkron iterbar åtgärdsinformationsobjekt som stöder växling