Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FormRecognizer] Rename for cross-language API consistency #8808

Merged
merged 12 commits into from
May 15, 2020
8 changes: 4 additions & 4 deletions sdk/formrecognizer/ai-form-recognizer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ async function main() {
const readStream = fs.createReadStream(path);

const client = new FormRecognizerClient(endpoint, new AzureKeyCredential(apiKey));
const poller = await client.beginRecognizeForms(modelId, readStream, "application/pdf", {
const poller = await client.beginRecognizeCustomForms(modelId, readStream, "application/pdf", {
onProgress: (state) => { console.log(`status: ${state.status}`); }
});
await poller.pollUntilDone();
Expand Down Expand Up @@ -315,7 +315,7 @@ async function main() {
const trainingClient = client.getFormTrainingClient();

// returns an async iteratable iterator that supports paging
const result = await trainingClient.listModels();
const result = await trainingClient.listCustomModels();
let i = 0;
for await (const modelInfo of result) {
console.log(`model ${i++}:`);
Expand All @@ -324,7 +324,7 @@ async function main() {

// using `iter.next()`
i = 1;
let iter = trainingClient.listModels();
let iter = trainingClient.listCustomModels();
let modelItem = await iter.next();
while (!modelItem.done) {
console.log(`model ${i++}: ${modelItem.value.modelId}`);
Expand All @@ -333,7 +333,7 @@ async function main() {

// using `byPage()`
i = 1;
for await (const response of trainingClient.listModels().byPage()) {
for await (const response of trainingClient.listCustomModels().byPage()) {
for (const modelInfo of response.modelList) {
console.log(`model ${i++}: ${modelInfo.modelId}`);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import { RestResponse } from '@azure/core-http';

// @public
export interface AccountProperties {
count: number;
limit: number;
customModelCount: number;
customModelLimit: number;
}

// @public
Expand Down Expand Up @@ -74,32 +74,40 @@ export type ContentPollerLike = PollerLike<PollOperationState<RecognizeContentRe
// @public
export type ContentType = "application/pdf" | "image/jpeg" | "image/png" | "image/tiff";

// @public (undocumented)
export interface CustomFormField {
accuracy?: number;
name: string;
}

// @public
export interface CustomFormModel {
createdOn: Date;
errors?: ErrorInformation[];
errors?: FormRecognizerError[];
lastModified: Date;
modelId: string;
models?: CustomFormSubModel[];
status: ModelStatus;
trainingDocuments?: TrainingDocumentInfo[];
}

// @public
export interface CustomFormModelInfo {
createdOn: Date;
lastModified: Date;
modelId: string;
status: ModelStatus;
}

// @public (undocumented)
export interface CustomFormSubModel {
accuracy?: number;
fields: {
[propertyName: string]: CustomFormSubModelField;
[propertyName: string]: CustomFormField;
};
formType: string;
}

// @public (undocumented)
export interface CustomFormSubModelField {
accuracy?: number;
name: string;
}

// Warning: (ae-forgotten-export) The symbol "CommonFieldValue" needs to be exported by the entry point index.d.ts
//
// @public
Expand All @@ -111,14 +119,6 @@ export type DateFieldValue = {
// @public
export type DeleteModelOptions = FormRecognizerOperationOptions;

// @public (undocumented)
export interface ErrorInformation {
// (undocumented)
code: string;
// (undocumented)
message: string;
}

// @public
export type FieldValue = StringFieldValue | DateFieldValue | TimeFieldValue | PhoneNumberFieldValue | NumberFieldValue | IntegerFieldValue | ArrayFieldValue | ObjectFieldValue;

Expand All @@ -128,10 +128,10 @@ export type FieldValueTypes = string | Date | number | FieldValue[] | {
};

// @public
export type FormElement = FormWord | FormLine;
export type FormContent = FormWord | FormLine;

// @public
export interface FormElementCommon {
export interface FormContentCommon {
boundingBox: Point2D[];
pageNumber: number;
text: string;
Expand All @@ -140,7 +140,7 @@ export interface FormElementCommon {
// @public
export interface FormField {
confidence?: number;
fieldLabel?: FormText;
labelText?: FormText;
name?: string;
value?: FieldValueTypes;
valueText?: FormText;
Expand All @@ -154,15 +154,15 @@ export interface FormFieldsReport {
}

// @public
export interface FormLine extends FormElementCommon {
export interface FormLine extends FormContentCommon {
kind: "line";
words: FormWord[];
}

// @public
export interface FormModel {
keys: KeysResult;
modelInfo: ModelInfo;
modelInfo: CustomFormModelInfo;
trainResult?: FormTrainResult;
}

Expand Down Expand Up @@ -198,11 +198,11 @@ export type FormPollerLike = PollerLike<PollOperationState<RecognizeFormResultRe
export class FormRecognizerClient {
constructor(endpointUrl: string, credential: KeyCredential, options?: FormRecognizerClientOptions);
beginRecognizeContent(data: FormRecognizerRequestBody, contentType?: ContentType, options?: BeginRecognizeContentOptions): Promise<ContentPollerLike>;
beginRecognizeContentFromUrl(documentUrl: string, options?: BeginRecognizeContentOptions): Promise<ContentPollerLike>;
beginRecognizeForms(modelId: string, data: FormRecognizerRequestBody, contentType?: ContentType, options?: BeginRecognizeFormsOptions): Promise<FormPollerLike>;
beginRecognizeFormsFromUrl(modelId: string, documentUrl: string, options?: BeginRecognizeFormsOptions): Promise<PollerLike<PollOperationState<RecognizeFormResultResponse>, RecognizeFormResultResponse>>;
beginRecognizeContentFromUrl(formFileUrl: string, options?: BeginRecognizeContentOptions): Promise<ContentPollerLike>;
beginRecognizeCustomForms(modelId: string, data: FormRecognizerRequestBody, contentType?: ContentType, options?: BeginRecognizeFormsOptions): Promise<FormPollerLike>;
beginRecognizeCustomFormsFromUrl(modelId: string, formFileUrl: string, options?: BeginRecognizeFormsOptions): Promise<PollerLike<PollOperationState<RecognizeFormResultResponse>, RecognizeFormResultResponse>>;
beginRecognizeReceipts(data: FormRecognizerRequestBody, contentType?: ContentType, options?: BeginRecognizeReceiptsOptions): Promise<ReceiptPollerLike>;
beginRecognizeReceiptsFromUrl(documentUrl: string, options?: BeginRecognizeReceiptsOptions): Promise<ReceiptPollerLike>;
beginRecognizeReceiptsFromUrl(receiptFileUrl: string, options?: BeginRecognizeReceiptsOptions): Promise<ReceiptPollerLike>;
readonly endpointUrl: string;
getFormTrainingClient(): FormTrainingClient;
}
Expand All @@ -211,6 +211,12 @@ export class FormRecognizerClient {
export interface FormRecognizerClientOptions extends PipelineOptions {
}

// @public
export interface FormRecognizerError {
code: string;
message: string;
}

// @public
export interface FormRecognizerOperationOptions extends OperationOptions {
}
Expand All @@ -220,7 +226,7 @@ export type FormRecognizerRequestBody = Blob | ArrayBuffer | ArrayBufferView | N

// @public
export interface FormResult {
errors?: ErrorInformation[];
errors?: FormRecognizerError[];
forms?: RecognizedForm[];
version: string;
}
Expand All @@ -243,7 +249,7 @@ export interface FormTableCell {
rowIndex: number;
rowSpan?: number;
text: string;
textContent?: FormElement[];
textContent?: FormContent[];
}

// @public
Expand All @@ -255,28 +261,28 @@ export interface FormTableRow {
export interface FormText {
boundingBox?: Point2D[];
text?: string;
textContent?: FormElement[];
textContent?: FormContent[];
}

// @public
export class FormTrainingClient {
constructor(endpointUrl: string, credential: KeyCredential, options?: FormRecognizerClientOptions);
beginTraining(blobContainerUrl: string, useLabels?: boolean, options?: BeginTrainingOptions<FormModelResponse>): Promise<PollerLike<PollOperationState<FormModelResponse>, FormModelResponse>>;
beginTraining(trainingFilesUrl: string, useTrainingLabels?: boolean, options?: BeginTrainingOptions<FormModelResponse>): Promise<PollerLike<PollOperationState<FormModelResponse>, FormModelResponse>>;
deleteModel(modelId: string, options?: DeleteModelOptions): Promise<RestResponse>;
readonly endpointUrl: string;
getAccountProperties(options?: GetAccountPropertiesOptions): Promise<AccountProperties>;
getModel(modelId: string, options?: GetModelOptions): Promise<FormModelResponse>;
listModels(options?: ListModelsOptions): PagedAsyncIterableIterator<ModelInfo, ListModelsResponseModel>;
getCustomModel(modelId: string, options?: GetModelOptions): Promise<FormModelResponse>;
listCustomModels(options?: ListModelsOptions): PagedAsyncIterableIterator<CustomFormModelInfo, ListModelsResponseModel>;
}

// @public
export interface FormTrainResult {
errors?: ErrorInformation[];
errors?: FormRecognizerError[];
trainingDocuments: TrainingDocumentInfo[];
}

// @public
export interface FormWord extends FormElementCommon {
export interface FormWord extends FormContentCommon {
confidence?: number;
containingLine?: FormLine;
kind: "word";
Expand Down Expand Up @@ -534,7 +540,7 @@ export type TimeFieldValue = {
// @public
export interface TrainingDocumentInfo {
documentName: string;
errors: ErrorInformation[];
errors: FormRecognizerError[];
pageCount: number;
status: TrainStatus;
}
Expand All @@ -548,7 +554,7 @@ export type TrainModelOptions = FormRecognizerOperationOptions & {
// @public
export interface TrainResult {
averageModelAccuracy?: number;
errors?: ErrorInformation[];
errors?: FormRecognizerError[];
fields?: FormFieldsReport[];
trainingDocuments: TrainingDocumentInfo[];
}
Expand Down Expand Up @@ -589,7 +595,7 @@ export type ValueTypes = "string" | "date" | "time" | "phoneNumber" | "number" |
// Warnings were encountered during analysis:
//
// src/formRecognizerClient.ts:70:3 - (ae-forgotten-export) The symbol "BeginRecognizePollState" needs to be exported by the entry point index.d.ts
// src/formTrainingClient.ts:68:3 - (ae-forgotten-export) The symbol "BeginTrainingPollState" needs to be exported by the entry point index.d.ts
// src/formTrainingClient.ts:66:3 - (ae-forgotten-export) The symbol "BeginTrainingPollState" needs to be exported by the entry point index.d.ts

// (No @packageDocumentation comment for this package)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ async function main() {
// First, we see how many custom models we have, and what our limit is
const accountProperties = await client.getAccountProperties();
console.log(
`Our account has ${accountProperties.count} custom models, and we can have at most ${accountProperties.limit} custom models`
`Our account has ${accountProperties.customModelCount} custom models, and we can have at most ${accountProperties.customModelLimit} custom models`
);

// Next, we get a paged async iterator of all of our custom models
const result = client.listModels();
const result = client.listCustomModels();

// We could print out information about first ten models
// and save the first model id for later use
Expand All @@ -49,7 +49,7 @@ async function main() {
}

// Now we'll get the first custom model in the paged list
const model = await client.getModel(firstModel.modelId);
const model = await client.getCustomModel(firstModel.modelId);
console.log(`Model Id: ${model.modelId}`);
console.log(`Status: ${model.status}`);
console.log("Documents used in training: [");
Expand All @@ -61,7 +61,7 @@ async function main() {
// Finally, we can delete this model if we want (for example, if its status is 'invalid')
// await client.deleteModel(firstModel.modelId);
// try {
// const deleted = await client.getModel(firstModel.modelId);
// const deleted = await client.getCustomModel(firstModel.modelId);
// console.log(deleted);
// } catch (err) {
// // Expected
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ async function main() {
// The recognized form fields with a custom model from training without labels will also include data about recognized labels.
const field = form.fields[fieldName];
console.log(
`\tField ${fieldName} has label '${field.fieldLabel.text}' with a confidence score of ${field.confidence}`
`\tField ${fieldName} has label '${field.labelText.text}' with a confidence score of ${field.confidence}`
);
console.log(
`\tField ${fieldName} has value '${field.value}' with a confidence score of ${field.confidence}`
Expand All @@ -63,7 +63,7 @@ async function recognizeCustomForm(path, endpoint, apiKey, labeledModelId) {
console.log("# Recognizing...");
const readStream = fs.createReadStream(path);
const client = new FormRecognizerClient(endpoint, new AzureKeyCredential(apiKey));
const poller = await client.beginRecognizeForms(labeledModelId, readStream, "application/pdf", {
const poller = await client.beginRecognizeCustomForms(labeledModelId, readStream, "application/pdf", {
onProgress: (state) => {
console.log(`\tstatus: ${state.status}`);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ async function main() {
const readStream = fs.createReadStream(path);

const client = new FormRecognizerClient(endpoint, new AzureKeyCredential(apiKey));
const poller = await client.beginRecognizeForms(modelId, readStream, "application/pdf", {
const poller = await client.beginRecognizeCustomForms(modelId, readStream, "application/pdf", {
onProgress: (state) => {
console.log(`status: ${state.status}`);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async function main() {

const client = new FormTrainingClient(endpoint, new AzureKeyCredential(apiKey));

const result = await client.listModels();
const result = await client.listCustomModels();
let i = 0;
for await (const modelInfo of result) {
console.log(`model ${i++}:`);
Expand All @@ -27,7 +27,7 @@ async function main() {

// using `iter.next()`
i = 1;
let iter = client.listModels();
let iter = client.listCustomModels();
let modelItem = await iter.next();
while (!modelItem.done) {
console.log(`model ${i++}: ${modelItem.value.modelId}`);
Expand All @@ -36,7 +36,7 @@ async function main() {

// using `byPage()`
i = 1;
for await (const response of client.listModels().byPage()) {
for await (const response of client.listCustomModels().byPage()) {
for (const modelInfo of response.modelList) {
console.log(`model ${i++}: ${modelInfo.modelId}`);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ async function main() {
const readStream = fs.createReadStream(path);

const client = new FormRecognizerClient(endpoint, new AzureKeyCredential(apiKey));
const poller = await client.beginRecognizeForms(modelId, readStream, "application/pdf", {
const poller = await client.beginRecognizeCustomForms(modelId, readStream, "application/pdf", {
onProgress: (state) => {
console.log(`status: ${state.status}`);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ export async function main() {
// First, we see how many custom models we have, and what our limit is
const accountProperties = await client.getAccountProperties();
console.log(
`Our account has ${accountProperties.count} custom models, and we can have at most ${accountProperties.limit} custom models`
`Our account has ${accountProperties.customModelCount} custom models, and we can have at most ${accountProperties.customModelLimit} custom models`
);

// Next, we get a paged async iterator of all of our custom models
const result = client.listModels();
const result = client.listCustomModels();

// We could print out information about first ten models
// and save the first model id for later use
Expand All @@ -50,7 +50,7 @@ export async function main() {
}

// Now we'll get the first custom model in the paged list
const model = await client.getModel(firstModel.modelId);
const model = await client.getCustomModel(firstModel.modelId);
console.log(`Model Id: ${model.modelId}`);
console.log(`Status: ${model.status}`);
console.log("Documents used in training: [");
Expand All @@ -62,7 +62,7 @@ export async function main() {
// Finally, we can delete this model if we want (for example, if its status is 'invalid')
// await client.deleteModel(firstModel.modelId);
// try {
// const deleted = await client.getModel(firstModel.modelId);
// const deleted = await client.getCustomModel(firstModel.modelId);
// console.log(deleted);
// } catch (err) {
// // Expected
Expand Down
Loading