From 0296859fd013c25b3e0cbbe8a80d4fefdad01946 Mon Sep 17 00:00:00 2001 From: Deyaaeldeen Almahallawi Date: Mon, 11 Oct 2021 21:52:03 +0000 Subject: [PATCH 1/2] address archboard feedback --- .../ai-text-analytics/CHANGELOG.md | 2 +- .../review/ai-text-analytics.api.md | 152 +++++++++--------- .../src/analyzeActionsResult.ts | 92 ++++++----- .../ai-text-analytics/src/index.ts | 38 ++--- ...sult.ts => multiCategoryClassifyResult.ts} | 22 +-- ...ts => multiCategoryClassifyResultArray.ts} | 21 ++- ...ult.ts => singleCategoryClassifyResult.ts} | 22 +-- ...s => singleCategoryClassifyResultArray.ts} | 21 ++- .../src/textAnalyticsClient.ts | 20 +-- .../test/public/textAnalyticsClient.spec.ts | 8 +- 10 files changed, 195 insertions(+), 203 deletions(-) rename sdk/textanalytics/ai-text-analytics/src/{classifyDocumentMultiCategoriesResult.ts => multiCategoryClassifyResult.ts} (62%) rename sdk/textanalytics/ai-text-analytics/src/{classifyDocumentMultiCategoriesResultArray.ts => multiCategoryClassifyResultArray.ts} (64%) rename sdk/textanalytics/ai-text-analytics/src/{classifyDocumentSingleCategoryResult.ts => singleCategoryClassifyResult.ts} (65%) rename sdk/textanalytics/ai-text-analytics/src/{classifyDocumentSingleCategoryResultArray.ts => singleCategoryClassifyResultArray.ts} (65%) diff --git a/sdk/textanalytics/ai-text-analytics/CHANGELOG.md b/sdk/textanalytics/ai-text-analytics/CHANGELOG.md index ccbcd6f609ac..42bd1ddb73f9 100644 --- a/sdk/textanalytics/ai-text-analytics/CHANGELOG.md +++ b/sdk/textanalytics/ai-text-analytics/CHANGELOG.md @@ -5,7 +5,7 @@ ### Features Added - We are now targeting the service's v3.2-preview.2 API as the default instead of v3.2-preview.1. -- Adding support for a three new actions in `beginAnalyzeActions`: `recognizeCustomEntities`, `classifyDocumentSingleCategory`, and `classifyDocumentMultiCategories`. The new actions allow you to use custom models to perform entity recognition and classification actions. +- Adding support for a three new actions in `beginAnalyzeActions`: `recognizeCustomEntities`, `singleCategoryClassify`, and `multiCategoryClassify`. The new actions allow you to use custom models to perform entity recognition and classification actions. ### Breaking Changes diff --git a/sdk/textanalytics/ai-text-analytics/review/ai-text-analytics.api.md b/sdk/textanalytics/ai-text-analytics/review/ai-text-analytics.api.md index f7ceb12186c0..619b5c06fefb 100644 --- a/sdk/textanalytics/ai-text-analytics/review/ai-text-analytics.api.md +++ b/sdk/textanalytics/ai-text-analytics/review/ai-text-analytics.api.md @@ -35,14 +35,14 @@ export type AnalyzeActionsPollerLike = PollerLike { - deploymentName: string; - projectName: string; - statistics?: TextDocumentBatchStatistics; -} - -// @public -export interface ClassifyDocumentMultiCategoriesSuccessResult extends TextAnalyticsSuccessResult { - classifications: DocumentClassification[]; -} - -// @public -export interface ClassifyDocumentSingleCategoryAction extends CustomTextAnalyticsAction { - disableServiceLogs?: boolean; -} - -// @public -export type ClassifyDocumentSingleCategoryActionErrorResult = TextAnalyticsActionErrorResult; - -// @public -export type ClassifyDocumentSingleCategoryActionResult = ClassifyDocumentSingleCategoryActionSuccessResult | ClassifyDocumentSingleCategoryActionErrorResult; - -// @public -export interface ClassifyDocumentSingleCategoryActionSuccessResult extends TextAnalyticsActionSuccessState { - results: ClassifyDocumentSingleCategoryResultArray; -} - -// @public -export type ClassifyDocumentSingleCategoryErrorResult = TextAnalyticsErrorResult; - -// @public -export type ClassifyDocumentSingleCategoryResult = ClassifyDocumentSingleCategorySuccessResult | ClassifyDocumentSingleCategoryErrorResult; - -// @public -export interface ClassifyDocumentSingleCategoryResultArray extends Array { - deploymentName: string; - projectName: string; - statistics?: TextDocumentBatchStatistics; -} - -// @public -export interface ClassifyDocumentSingleCategorySuccessResult extends TextAnalyticsSuccessResult { - classification: DocumentClassification; -} - // @public export interface CustomTextAnalyticsAction { actionName?: string; @@ -254,10 +190,6 @@ export interface DetectLanguageSuccessResult extends TextAnalyticsSuccessResult readonly primaryLanguage: DetectedLanguage; } -// @public -export interface DocumentClassification extends ClassificationResult { -} - // @public export type DocumentSentimentLabel = "positive" | "neutral" | "negative" | "mixed"; @@ -512,6 +444,40 @@ export interface Match { text: string; } +// @public +export interface MultiCategoryClassifyAction extends CustomTextAnalyticsAction { + disableServiceLogs?: boolean; +} + +// @public +export type MultiCategoryClassifyActionErrorResult = TextAnalyticsActionErrorResult; + +// @public +export type MultiCategoryClassifyActionResult = MultiCategoryClassifyActionSuccessResult | MultiCategoryClassifyActionErrorResult; + +// @public +export interface MultiCategoryClassifyActionSuccessResult extends TextAnalyticsActionSuccessState { + results: MultiCategoryClassifyResultArray; +} + +// @public +export type MultiCategoryClassifyErrorResult = TextAnalyticsErrorResult; + +// @public +export type MultiCategoryClassifyResult = MultiCategoryClassifySuccessResult | MultiCategoryClassifyErrorResult; + +// @public +export interface MultiCategoryClassifyResultArray extends Array { + deploymentName: string; + projectName: string; + statistics?: TextDocumentBatchStatistics; +} + +// @public +export interface MultiCategoryClassifySuccessResult extends TextAnalyticsSuccessResult { + classifications: ClassificationCategory[]; +} + // @public export interface OperationMetadata { createdOn: Date; @@ -746,6 +712,40 @@ export interface SentimentConfidenceScores { positive: number; } +// @public +export interface SingleCategoryClassifyAction extends CustomTextAnalyticsAction { + disableServiceLogs?: boolean; +} + +// @public +export type SingleCategoryClassifyActionErrorResult = TextAnalyticsActionErrorResult; + +// @public +export type SingleCategoryClassifyActionResult = SingleCategoryClassifyActionSuccessResult | SingleCategoryClassifyActionErrorResult; + +// @public +export interface SingleCategoryClassifyActionSuccessResult extends TextAnalyticsActionSuccessState { + results: SingleCategoryClassifyResultArray; +} + +// @public +export type SingleCategoryClassifyErrorResult = TextAnalyticsErrorResult; + +// @public +export type SingleCategoryClassifyResult = SingleCategoryClassifySuccessResult | SingleCategoryClassifyErrorResult; + +// @public +export interface SingleCategoryClassifyResultArray extends Array { + deploymentName: string; + projectName: string; + statistics?: TextDocumentBatchStatistics; +} + +// @public +export interface SingleCategoryClassifySuccessResult extends TextAnalyticsSuccessResult { + classification: ClassificationCategory; +} + // @public export type StringIndexType = "TextElement_v8" | "UnicodeCodePoint" | "Utf16CodeUnit"; @@ -789,14 +789,14 @@ export interface TextAnalyticsActionErrorResult { // @public export interface TextAnalyticsActions { analyzeSentimentActions?: AnalyzeSentimentAction[]; - classifyDocumentMultiCategoriesActions?: ClassifyDocumentMultiCategoriesAction[]; - classifyDocumentSingleCategoryActions?: ClassifyDocumentSingleCategoryAction[]; extractKeyPhrasesActions?: ExtractKeyPhrasesAction[]; extractSummaryActions?: ExtractSummaryAction[]; + multiCategoryClassifyActions?: MultiCategoryClassifyAction[]; recognizeCustomEntitiesActions?: RecognizeCustomEntitiesAction[]; recognizeEntitiesActions?: RecognizeCategorizedEntitiesAction[]; recognizeLinkedEntitiesActions?: RecognizeLinkedEntitiesAction[]; recognizePiiEntitiesActions?: RecognizePiiEntitiesAction[]; + singleCategoryClassifyActions?: SingleCategoryClassifyAction[]; } // @public diff --git a/sdk/textanalytics/ai-text-analytics/src/analyzeActionsResult.ts b/sdk/textanalytics/ai-text-analytics/src/analyzeActionsResult.ts index 17e6a2f06996..fb1b3657c100 100644 --- a/sdk/textanalytics/ai-text-analytics/src/analyzeActionsResult.ts +++ b/sdk/textanalytics/ai-text-analytics/src/analyzeActionsResult.ts @@ -7,13 +7,13 @@ import { makeAnalyzeSentimentResultArray } from "./analyzeSentimentResultArray"; import { - ClassifyDocumentMultiCategoriesResultArray, - makeClassifyDocumentMultiCategoriesResultArray -} from "./classifyDocumentMultiCategoriesResultArray"; + MultiCategoryClassifyResultArray, + makeMultiCategoryClassifyResultArray +} from "./multiCategoryClassifyResultArray"; import { - ClassifyDocumentSingleCategoryResultArray, - makeClassifyDocumentSingleCategoryResultArray -} from "./classifyDocumentSingleCategoryResultArray"; + SingleCategoryClassifyResultArray, + makeSingleCategoryClassifyResultArray +} from "./singleCategoryClassifyResultArray"; import { ExtractKeyPhrasesResultArray, makeExtractKeyPhrasesResultArray @@ -76,11 +76,11 @@ export interface AnalyzeActionsResult { /** * Array of the results for each custom classify document single category action. */ - classifyDocumentSingleCategoryResults: ClassifyDocumentSingleCategoryActionResult[]; + singleCategoryClassifyResults: SingleCategoryClassifyActionResult[]; /** - * Array of the results for each custom classify document multi categories action. + * Array of the results for each custom classify document multi category action. */ - classifyDocumentMultiCategoriesResults: ClassifyDocumentMultiCategoriesActionResult[]; + multiCategoryClassifyResults: MultiCategoryClassifyActionResult[]; } /** @@ -271,48 +271,46 @@ export type RecognizeCustomEntitiesActionResult = /** * The error of a custom classify document single category action. */ -export type ClassifyDocumentSingleCategoryActionErrorResult = TextAnalyticsActionErrorResult; +export type SingleCategoryClassifyActionErrorResult = TextAnalyticsActionErrorResult; /** * The results of a succeeded custom classify document single category action. */ -export interface ClassifyDocumentSingleCategoryActionSuccessResult - extends TextAnalyticsActionSuccessState { +export interface SingleCategoryClassifyActionSuccessResult extends TextAnalyticsActionSuccessState { /** * Array of the results for each custom classify document single category action. */ - results: ClassifyDocumentSingleCategoryResultArray; + results: SingleCategoryClassifyResultArray; } /** * The result of a custom classify document single category action. */ -export type ClassifyDocumentSingleCategoryActionResult = - | ClassifyDocumentSingleCategoryActionSuccessResult - | ClassifyDocumentSingleCategoryActionErrorResult; +export type SingleCategoryClassifyActionResult = + | SingleCategoryClassifyActionSuccessResult + | SingleCategoryClassifyActionErrorResult; /** - * The error of a custom classify document multi categories action. + * The error of a custom classify document multi category action. */ -export type ClassifyDocumentMultiCategoriesActionErrorResult = TextAnalyticsActionErrorResult; +export type MultiCategoryClassifyActionErrorResult = TextAnalyticsActionErrorResult; /** - * The results of a succeeded custom classify document multi categories action. + * The results of a succeeded custom classify document multi category action. */ -export interface ClassifyDocumentMultiCategoriesActionSuccessResult - extends TextAnalyticsActionSuccessState { +export interface MultiCategoryClassifyActionSuccessResult extends TextAnalyticsActionSuccessState { /** - * Array of the results for each custom classify document multi categories action. + * Array of the results for each custom classify document multi category action. */ - results: ClassifyDocumentMultiCategoriesResultArray; + results: MultiCategoryClassifyResultArray; } /** - * The result of a custom classify document multi categories action. + * The result of a custom classify document multi category action. */ -export type ClassifyDocumentMultiCategoriesActionResult = - | ClassifyDocumentMultiCategoriesActionSuccessResult - | ClassifyDocumentMultiCategoriesActionErrorResult; +export type MultiCategoryClassifyActionResult = + | MultiCategoryClassifyActionSuccessResult + | MultiCategoryClassifyActionErrorResult; /** * The results of an analyze Actions operation represented as a paged iterator that @@ -348,8 +346,8 @@ type TextAnalyticsActionType = | "AnalyzeSentiment" | "ExtractSummary" | "RecognizeCustomEntities" - | "ClassifyDocumentSingleCategory" - | "ClassifyDocumentMultiCategories"; + | "SingleCategoryClassify" + | "MultiCategoryClassify"; /** * The type of an action error with the type of the action that erred and its @@ -405,10 +403,10 @@ function convertTaskTypeToActionType(taskType: string): TextAnalyticsActionType return "RecognizeCustomEntities"; } case "customSingleClassificationTasks": { - return "ClassifyDocumentSingleCategory"; + return "SingleCategoryClassify"; } case "customMultiClassificationTasks": { - return "ClassifyDocumentMultiCategories"; + return "MultiCategoryClassify"; } default: { throw new Error(`unexpected action type from the service: ${taskType}`); @@ -462,8 +460,8 @@ function categorizeActionErrors( analyzeSentimentActionErrors: TextAnalyticsActionError[], extractSummarySentencesActionErrors: TextAnalyticsActionError[], recognizeCustomEntitiesActionErrors: TextAnalyticsActionError[], - classifyDocumentSingleCategoryActionErrors: TextAnalyticsActionError[], - classifyDocumentMultiCategoriesActionErrors: TextAnalyticsActionError[] + singleCategoryClassifyActionErrors: TextAnalyticsActionError[], + multiCategoryClassifyActionErrors: TextAnalyticsActionError[] ): void { for (const error of erredActions) { const actionError = parseActionError(error); @@ -496,12 +494,12 @@ function categorizeActionErrors( recognizeCustomEntitiesActionErrors.push(actionError); break; } - case "ClassifyDocumentSingleCategory": { - classifyDocumentSingleCategoryActionErrors.push(actionError); + case "SingleCategoryClassify": { + singleCategoryClassifyActionErrors.push(actionError); break; } - case "ClassifyDocumentMultiCategories": { - classifyDocumentMultiCategoriesActionErrors.push(actionError); + case "MultiCategoryClassify": { + multiCategoryClassifyActionErrors.push(actionError); break; } } @@ -586,8 +584,8 @@ export function createAnalyzeActionsResult( const analyzeSentimentActionErrors: TextAnalyticsActionError[] = []; const extractSummarySentencesActionErrors: TextAnalyticsActionError[] = []; const recognizeCustomEntitiesActionErrors: TextAnalyticsActionError[] = []; - const classifyDocumentSingleCategoryActionErrors: TextAnalyticsActionError[] = []; - const classifyDocumentMultiCategoriesActionErrors: TextAnalyticsActionError[] = []; + const singleCategoryClassifyActionErrors: TextAnalyticsActionError[] = []; + const multiCategoryClassifyActionErrors: TextAnalyticsActionError[] = []; categorizeActionErrors( response?.errors ?? [], recognizeEntitiesActionErrors, @@ -597,8 +595,8 @@ export function createAnalyzeActionsResult( analyzeSentimentActionErrors, extractSummarySentencesActionErrors, recognizeCustomEntitiesActionErrors, - classifyDocumentSingleCategoryActionErrors, - classifyDocumentMultiCategoriesActionErrors + singleCategoryClassifyActionErrors, + multiCategoryClassifyActionErrors ); return { recognizeEntitiesResults: makeActionResult( @@ -643,17 +641,17 @@ export function createAnalyzeActionsResult( response.tasks.customEntityRecognitionTasks ?? [], recognizeCustomEntitiesActionErrors ), - classifyDocumentSingleCategoryResults: makeActionResult( + singleCategoryClassifyResults: makeActionResult( documents, - makeClassifyDocumentSingleCategoryResultArray, + makeSingleCategoryClassifyResultArray, response.tasks.customSingleClassificationTasks ?? [], - classifyDocumentSingleCategoryActionErrors + singleCategoryClassifyActionErrors ), - classifyDocumentMultiCategoriesResults: makeActionResult( + multiCategoryClassifyResults: makeActionResult( documents, - makeClassifyDocumentMultiCategoriesResultArray, + makeMultiCategoryClassifyResultArray, response.tasks.customMultiClassificationTasks ?? [], - classifyDocumentMultiCategoriesActionErrors + multiCategoryClassifyActionErrors ) }; } diff --git a/sdk/textanalytics/ai-text-analytics/src/index.ts b/sdk/textanalytics/ai-text-analytics/src/index.ts index b0f90c102efa..5176a0dd5cfc 100644 --- a/sdk/textanalytics/ai-text-analytics/src/index.ts +++ b/sdk/textanalytics/ai-text-analytics/src/index.ts @@ -36,8 +36,8 @@ export { ExtractSummaryAction, KnownSummarySentencesSortBy as KnownSummarySentencesOrderBy, RecognizeCustomEntitiesAction, - ClassifyDocumentSingleCategoryAction, - ClassifyDocumentMultiCategoriesAction + SingleCategoryClassifyAction, + MultiCategoryClassifyAction } from "./textAnalyticsClient"; export { TextAnalyticsOperationOptions } from "./textAnalyticsOperationOptions"; export { @@ -90,18 +90,18 @@ export { } from "./recognizeCustomEntitiesResult"; export { RecognizeCustomEntitiesResultArray } from "./recognizeCustomEntitiesResultArray"; export { - ClassifyDocumentSingleCategoryErrorResult, - ClassifyDocumentSingleCategoryResult, - ClassifyDocumentSingleCategorySuccessResult, - DocumentClassification -} from "./classifyDocumentSingleCategoryResult"; -export { ClassifyDocumentSingleCategoryResultArray } from "./classifyDocumentSingleCategoryResultArray"; + SingleCategoryClassifyErrorResult, + SingleCategoryClassifyResult, + SingleCategoryClassifySuccessResult, + ClassificationCategory +} from "./singleCategoryClassifyResult"; +export { SingleCategoryClassifyResultArray } from "./singleCategoryClassifyResultArray"; export { - ClassifyDocumentMultiCategoriesErrorResult, - ClassifyDocumentMultiCategoriesResult, - ClassifyDocumentMultiCategoriesSuccessResult -} from "./classifyDocumentMultiCategoriesResult"; -export { ClassifyDocumentMultiCategoriesResultArray } from "./classifyDocumentMultiCategoriesResultArray"; + MultiCategoryClassifyErrorResult, + MultiCategoryClassifyResult, + MultiCategoryClassifySuccessResult +} from "./multiCategoryClassifyResult"; +export { MultiCategoryClassifyResultArray } from "./multiCategoryClassifyResultArray"; export { RecognizeLinkedEntitiesResult, RecognizeLinkedEntitiesErrorResult, @@ -148,12 +148,12 @@ export { RecognizeCustomEntitiesActionResult, RecongizeCustomEntitiesActionErrorResult, RecongizeCustomEntitiesActionSuccessResult, - ClassifyDocumentMultiCategoriesActionErrorResult, - ClassifyDocumentMultiCategoriesActionResult, - ClassifyDocumentMultiCategoriesActionSuccessResult, - ClassifyDocumentSingleCategoryActionErrorResult, - ClassifyDocumentSingleCategoryActionResult, - ClassifyDocumentSingleCategoryActionSuccessResult + MultiCategoryClassifyActionErrorResult, + MultiCategoryClassifyActionResult, + MultiCategoryClassifyActionSuccessResult, + SingleCategoryClassifyActionErrorResult, + SingleCategoryClassifyActionResult, + SingleCategoryClassifyActionSuccessResult } from "./analyzeActionsResult"; export { ErrorCode, diff --git a/sdk/textanalytics/ai-text-analytics/src/classifyDocumentMultiCategoriesResult.ts b/sdk/textanalytics/ai-text-analytics/src/multiCategoryClassifyResult.ts similarity index 62% rename from sdk/textanalytics/ai-text-analytics/src/classifyDocumentMultiCategoriesResult.ts rename to sdk/textanalytics/ai-text-analytics/src/multiCategoryClassifyResult.ts index 371e0f1a7ba8..abbb35d04daa 100644 --- a/sdk/textanalytics/ai-text-analytics/src/classifyDocumentMultiCategoriesResult.ts +++ b/sdk/textanalytics/ai-text-analytics/src/multiCategoryClassifyResult.ts @@ -8,37 +8,37 @@ import { makeTextAnalyticsErrorResult } from "./textAnalyticsResult"; import { TextAnalyticsError, MultiClassificationDocument } from "./generated/models"; -import { DocumentClassification } from "./classifyDocumentSingleCategoryResult"; +import { ClassificationCategory } from "./singleCategoryClassifyResult"; /** * The result of the custom classify document multi categories operation on a multi document. */ -export type ClassifyDocumentMultiCategoriesResult = - | ClassifyDocumentMultiCategoriesSuccessResult - | ClassifyDocumentMultiCategoriesErrorResult; +export type MultiCategoryClassifyResult = + | MultiCategoryClassifySuccessResult + | MultiCategoryClassifyErrorResult; /** * The result of the custom classify document multi categories operation on a multi document, * containing the result of the classification. */ -export interface ClassifyDocumentMultiCategoriesSuccessResult extends TextAnalyticsSuccessResult { +export interface MultiCategoryClassifySuccessResult extends TextAnalyticsSuccessResult { /** * The collection of classifications in the input document. */ - classifications: DocumentClassification[]; + classifications: ClassificationCategory[]; } /** * An error result from the custom classify document multi categories operation on a multi document. */ -export type ClassifyDocumentMultiCategoriesErrorResult = TextAnalyticsErrorResult; +export type MultiCategoryClassifyErrorResult = TextAnalyticsErrorResult; /** * @internal */ -export function makeClassifyDocumentMultiCategoriesResult( +export function makeMultiCategoryClassifyResult( result: MultiClassificationDocument -): ClassifyDocumentMultiCategoriesSuccessResult { +): MultiCategoryClassifySuccessResult { const { id, warnings, statistics, classifications } = result; return { ...makeTextAnalyticsSuccessResult(id, warnings, statistics), @@ -49,9 +49,9 @@ export function makeClassifyDocumentMultiCategoriesResult( /** * @internal */ -export function makeClassifyDocumentMultiCategoriesErrorResult( +export function makeMultiCategoryClassifyErrorResult( id: string, error: TextAnalyticsError -): ClassifyDocumentMultiCategoriesErrorResult { +): MultiCategoryClassifyErrorResult { return makeTextAnalyticsErrorResult(id, error); } diff --git a/sdk/textanalytics/ai-text-analytics/src/classifyDocumentMultiCategoriesResultArray.ts b/sdk/textanalytics/ai-text-analytics/src/multiCategoryClassifyResultArray.ts similarity index 64% rename from sdk/textanalytics/ai-text-analytics/src/classifyDocumentMultiCategoriesResultArray.ts rename to sdk/textanalytics/ai-text-analytics/src/multiCategoryClassifyResultArray.ts index a00b3cb3526b..19f747f56b78 100644 --- a/sdk/textanalytics/ai-text-analytics/src/classifyDocumentMultiCategoriesResultArray.ts +++ b/sdk/textanalytics/ai-text-analytics/src/multiCategoryClassifyResultArray.ts @@ -7,18 +7,17 @@ import { CustomMultiClassificationResult } from "./generated/models"; import { - ClassifyDocumentMultiCategoriesResult, - makeClassifyDocumentMultiCategoriesResult, - makeClassifyDocumentMultiCategoriesErrorResult -} from "./classifyDocumentMultiCategoriesResult"; + MultiCategoryClassifyResult, + makeMultiCategoryClassifyResult, + makeMultiCategoryClassifyErrorResult +} from "./multiCategoryClassifyResult"; import { combineSuccessfulAndErroneousDocumentsWithStatisticsAndCustomProjectInfo } from "./textAnalyticsResult"; /** - * Array of `CustomClassifyDocumentMultiCategoriesResult` objects corresponding to a batch of input documents, and + * Array of `MultiCategoryClassifyResult` objects corresponding to a batch of input documents, and * annotated with information about the batch operation. */ -export interface ClassifyDocumentMultiCategoriesResultArray - extends Array { +export interface MultiCategoryClassifyResultArray extends Array { /** * Statistics about the input document batch and how it was processed * by the service. This property will have a value when includeStatistics is set to true @@ -40,14 +39,14 @@ export interface ClassifyDocumentMultiCategoriesResultArray /** * @internal */ -export function makeClassifyDocumentMultiCategoriesResultArray( +export function makeMultiCategoryClassifyResultArray( input: TextDocumentInput[], response: CustomMultiClassificationResult -): ClassifyDocumentMultiCategoriesResultArray { +): MultiCategoryClassifyResultArray { return combineSuccessfulAndErroneousDocumentsWithStatisticsAndCustomProjectInfo( input, response, - makeClassifyDocumentMultiCategoriesResult, - makeClassifyDocumentMultiCategoriesErrorResult + makeMultiCategoryClassifyResult, + makeMultiCategoryClassifyErrorResult ); } diff --git a/sdk/textanalytics/ai-text-analytics/src/classifyDocumentSingleCategoryResult.ts b/sdk/textanalytics/ai-text-analytics/src/singleCategoryClassifyResult.ts similarity index 65% rename from sdk/textanalytics/ai-text-analytics/src/classifyDocumentSingleCategoryResult.ts rename to sdk/textanalytics/ai-text-analytics/src/singleCategoryClassifyResult.ts index a923b68642a7..dfc4e69f7b6a 100644 --- a/sdk/textanalytics/ai-text-analytics/src/classifyDocumentSingleCategoryResult.ts +++ b/sdk/textanalytics/ai-text-analytics/src/singleCategoryClassifyResult.ts @@ -16,37 +16,37 @@ import { /** * The result of the custom classify document single category operation on a single document. */ -export type ClassifyDocumentSingleCategoryResult = - | ClassifyDocumentSingleCategorySuccessResult - | ClassifyDocumentSingleCategoryErrorResult; +export type SingleCategoryClassifyResult = + | SingleCategoryClassifySuccessResult + | SingleCategoryClassifyErrorResult; /** * The result of the custom classify document single category operation on a single document, * containing the result of the classification. */ -export interface ClassifyDocumentSingleCategorySuccessResult extends TextAnalyticsSuccessResult { +export interface SingleCategoryClassifySuccessResult extends TextAnalyticsSuccessResult { /** * The classification result of the input document. */ - classification: DocumentClassification; + classification: ClassificationCategory; } /** * A classification result from a custom classify document single category action */ -export interface DocumentClassification extends ClassificationResult {} +export interface ClassificationCategory extends ClassificationResult {} /** * An error result from the custom classify document single category operation on a single document. */ -export type ClassifyDocumentSingleCategoryErrorResult = TextAnalyticsErrorResult; +export type SingleCategoryClassifyErrorResult = TextAnalyticsErrorResult; /** * @internal */ -export function makeClassifyDocumentSingleCategoryResult( +export function makeSingleCategoryClassifyResult( result: SingleClassificationDocument -): ClassifyDocumentSingleCategorySuccessResult { +): SingleCategoryClassifySuccessResult { const { id, warnings, statistics, classification } = result; return { ...makeTextAnalyticsSuccessResult(id, warnings, statistics), @@ -57,9 +57,9 @@ export function makeClassifyDocumentSingleCategoryResult( /** * @internal */ -export function makeClassifyDocumentSingleCategoryErrorResult( +export function makeSingleCategoryClassifyErrorResult( id: string, error: TextAnalyticsError -): ClassifyDocumentSingleCategoryErrorResult { +): SingleCategoryClassifyErrorResult { return makeTextAnalyticsErrorResult(id, error); } diff --git a/sdk/textanalytics/ai-text-analytics/src/classifyDocumentSingleCategoryResultArray.ts b/sdk/textanalytics/ai-text-analytics/src/singleCategoryClassifyResultArray.ts similarity index 65% rename from sdk/textanalytics/ai-text-analytics/src/classifyDocumentSingleCategoryResultArray.ts rename to sdk/textanalytics/ai-text-analytics/src/singleCategoryClassifyResultArray.ts index 33fe936d5b52..6d6419976ead 100644 --- a/sdk/textanalytics/ai-text-analytics/src/classifyDocumentSingleCategoryResultArray.ts +++ b/sdk/textanalytics/ai-text-analytics/src/singleCategoryClassifyResultArray.ts @@ -7,18 +7,17 @@ import { CustomSingleClassificationResult } from "./generated/models"; import { - ClassifyDocumentSingleCategoryResult, - makeClassifyDocumentSingleCategoryResult, - makeClassifyDocumentSingleCategoryErrorResult -} from "./classifyDocumentSingleCategoryResult"; + SingleCategoryClassifyResult, + makeSingleCategoryClassifyResult, + makeSingleCategoryClassifyErrorResult +} from "./singleCategoryClassifyResult"; import { combineSuccessfulAndErroneousDocumentsWithStatisticsAndCustomProjectInfo } from "./textAnalyticsResult"; /** - * Array of `CustomClassifyDocumentSingleCategoryResultArray` objects corresponding to a batch of input documents, and + * Array of `SingleCategoryClassifyResult` objects corresponding to a batch of input documents, and * annotated with information about the batch operation. */ -export interface ClassifyDocumentSingleCategoryResultArray - extends Array { +export interface SingleCategoryClassifyResultArray extends Array { /** * Statistics about the input document batch and how it was processed * by the service. This property will have a value when includeStatistics is set to true @@ -40,14 +39,14 @@ export interface ClassifyDocumentSingleCategoryResultArray /** * @internal */ -export function makeClassifyDocumentSingleCategoryResultArray( +export function makeSingleCategoryClassifyResultArray( input: TextDocumentInput[], response: CustomSingleClassificationResult -): ClassifyDocumentSingleCategoryResultArray { +): SingleCategoryClassifyResultArray { return combineSuccessfulAndErroneousDocumentsWithStatisticsAndCustomProjectInfo( input, response, - makeClassifyDocumentSingleCategoryResult, - makeClassifyDocumentSingleCategoryErrorResult + makeSingleCategoryClassifyResult, + makeSingleCategoryClassifyErrorResult ); } diff --git a/sdk/textanalytics/ai-text-analytics/src/textAnalyticsClient.ts b/sdk/textanalytics/ai-text-analytics/src/textAnalyticsClient.ts index 1d958ba3c6e4..a9788be3cad4 100644 --- a/sdk/textanalytics/ai-text-analytics/src/textAnalyticsClient.ts +++ b/sdk/textanalytics/ai-text-analytics/src/textAnalyticsClient.ts @@ -358,7 +358,7 @@ export interface RecognizeCustomEntitiesAction extends CustomTextAnalyticsAction /** * Options for an custom classify document single category action. */ -export interface ClassifyDocumentSingleCategoryAction extends CustomTextAnalyticsAction { +export interface SingleCategoryClassifyAction extends CustomTextAnalyticsAction { /** * If set to true, you opt-out of having your text input logged for troubleshooting. By default, Text Analytics * logs your input text for 48 hours, solely to allow for troubleshooting issues. Setting this parameter to true, @@ -370,7 +370,7 @@ export interface ClassifyDocumentSingleCategoryAction extends CustomTextAnalytic /** * Options for a custom classify document multi categories action. */ -export interface ClassifyDocumentMultiCategoriesAction extends CustomTextAnalyticsAction { +export interface MultiCategoryClassifyAction extends CustomTextAnalyticsAction { /** * If set to true, you opt-out of having your text input logged for troubleshooting. By default, Text Analytics * logs your input text for 48 hours, solely to allow for troubleshooting issues. Setting this parameter to true, @@ -412,13 +412,13 @@ export interface TextAnalyticsActions { */ recognizeCustomEntitiesActions?: RecognizeCustomEntitiesAction[]; /** - * A collection of descriptions of custom single classification actions. However, currently, the service can accept up to one action only for `customClassifyDocumentSingleCategory`. + * A collection of descriptions of custom single classification actions. However, currently, the service can accept up to one action only for `singleCategoryClassifyActions`. */ - classifyDocumentSingleCategoryActions?: ClassifyDocumentSingleCategoryAction[]; + singleCategoryClassifyActions?: SingleCategoryClassifyAction[]; /** - * A collection of descriptions of custom multi classification actions. However, currently, the service can accept up to one action only for `customClassifyDocumentMultiCategories`. + * A collection of descriptions of custom multi classification actions. However, currently, the service can accept up to one action only for `multiCategoryClassifyActions`. */ - classifyDocumentMultiCategoriesActions?: ClassifyDocumentMultiCategoriesAction[]; + multiCategoryClassifyActions?: MultiCategoryClassifyAction[]; } /** * Client class for interacting with Azure Text Analytics. @@ -1207,12 +1207,8 @@ function compileAnalyzeInput(actions: TextAnalyticsActions): GeneratedActions { customEntityRecognitionTasks: actions.recognizeCustomEntitiesActions?.map( compose(setStrEncodingParam, addParamsToTask) ), - customSingleClassificationTasks: actions.classifyDocumentSingleCategoryActions?.map( - addParamsToTask - ), - customMultiClassificationTasks: actions.classifyDocumentMultiCategoriesActions?.map( - addParamsToTask - ) + customSingleClassificationTasks: actions.singleCategoryClassifyActions?.map(addParamsToTask), + customMultiClassificationTasks: actions.multiCategoryClassifyActions?.map(addParamsToTask) }; } diff --git a/sdk/textanalytics/ai-text-analytics/test/public/textAnalyticsClient.spec.ts b/sdk/textanalytics/ai-text-analytics/test/public/textAnalyticsClient.spec.ts index 20f785abb68c..e67848c74676 100644 --- a/sdk/textanalytics/ai-text-analytics/test/public/textAnalyticsClient.spec.ts +++ b/sdk/textanalytics/ai-text-analytics/test/public/textAnalyticsClient.spec.ts @@ -992,7 +992,7 @@ matrix([["APIKey", "AAD"]] as const, async (authMethod: AuthMethod) => { const poller = await client.beginAnalyzeActions( docs, { - classifyDocumentSingleCategoryActions: [ + singleCategoryClassifyActions: [ { projectName: "659c1851-be0b-4142-b12a-087da9785926", deploymentName: "659c1851-be0b-4142-b12a-087da9785926" @@ -1005,7 +1005,7 @@ matrix([["APIKey", "AAD"]] as const, async (authMethod: AuthMethod) => { ); const results = await poller.pollUntilDone(); for await (const page of results) { - const classificationResult = page.classifyDocumentSingleCategoryResults; + const classificationResult = page.singleCategoryClassifyResults; if (classificationResult.length === 1) { const action = classificationResult[0]; if (!action.error) { @@ -1043,7 +1043,7 @@ matrix([["APIKey", "AAD"]] as const, async (authMethod: AuthMethod) => { const poller = await client.beginAnalyzeActions( docs, { - classifyDocumentMultiCategoriesActions: [ + multiCategoryClassifyActions: [ { projectName: "7cdace98-537b-494a-b69a-c19754718025", deploymentName: "7cdace98-537b-494a-b69a-c19754718025" @@ -1056,7 +1056,7 @@ matrix([["APIKey", "AAD"]] as const, async (authMethod: AuthMethod) => { ); const results = await poller.pollUntilDone(); for await (const page of results) { - const classificationResult = page.classifyDocumentMultiCategoriesResults; + const classificationResult = page.multiCategoryClassifyResults; if (classificationResult.length === 1) { const action = classificationResult[0]; if (!action.error) { From 3281ec8d35693ec7bd55ae1b6aec0b9fcdfcdf43 Mon Sep 17 00:00:00 2001 From: Deyaaeldeen Almahallawi Date: Mon, 11 Oct 2021 18:47:04 -0400 Subject: [PATCH 2/2] Update sdk/textanalytics/ai-text-analytics/src/multiCategoryClassifyResult.ts Co-authored-by: Krista Pratico --- .../ai-text-analytics/src/multiCategoryClassifyResult.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/textanalytics/ai-text-analytics/src/multiCategoryClassifyResult.ts b/sdk/textanalytics/ai-text-analytics/src/multiCategoryClassifyResult.ts index abbb35d04daa..784dfce91901 100644 --- a/sdk/textanalytics/ai-text-analytics/src/multiCategoryClassifyResult.ts +++ b/sdk/textanalytics/ai-text-analytics/src/multiCategoryClassifyResult.ts @@ -29,7 +29,7 @@ export interface MultiCategoryClassifySuccessResult extends TextAnalyticsSuccess } /** - * An error result from the custom classify document multi categories operation on a multi document. + * An error result from the custom classify document multi category operation on a multi document. */ export type MultiCategoryClassifyErrorResult = TextAnalyticsErrorResult;