From 925c1d91d9ab810ef5e2c26b9bd0866dea3bf01a Mon Sep 17 00:00:00 2001 From: deyaaeldeen Date: Mon, 28 Sep 2020 15:30:27 -0400 Subject: [PATCH 1/4] [Text Analytics] Remove length property --- .../review/ai-text-analytics.api.md | 5 --- .../src/analyzeSentimentResult.ts | 12 +------ .../src/generated/generatedClientContext.ts | 2 +- .../src/generated/models/index.ts | 20 ----------- .../src/generated/models/mappers.ts | 35 ------------------- .../ai-text-analytics/swagger/README.md | 12 +++++++ .../test/collections.spec.ts | 6 ---- .../test/textAnalyticsClient.spec.ts | 24 ++++++------- 8 files changed, 26 insertions(+), 90 deletions(-) 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 a5ceec9ebad4..8ac61eb98106 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 @@ -45,7 +45,6 @@ export interface AspectConfidenceScoreLabel { // @public export interface AspectSentiment { confidenceScores: AspectConfidenceScoreLabel; - length: number; offset: number; sentiment: TokenSentimentValue; text: string; @@ -100,7 +99,6 @@ export type DocumentSentimentLabel = "positive" | "neutral" | "negative" | "mixe export interface Entity { category: string; confidenceScore: number; - length: number; offset: number; subCategory?: string; text: string; @@ -149,7 +147,6 @@ export interface LinkedEntity { // @public export interface Match { confidenceScore: number; - length: number; offset: number; text: string; } @@ -240,7 +237,6 @@ export interface RecognizePiiEntitiesSuccessResult extends TextAnalyticsSuccessR export interface SentenceOpinion { confidenceScores: AspectConfidenceScoreLabel; isNegated: boolean; - length: number; offset: number; sentiment: TokenSentimentValue; text: string; @@ -249,7 +245,6 @@ export interface SentenceOpinion { // @public export interface SentenceSentiment { confidenceScores: SentimentConfidenceScores; - length: number; minedOpinions: MinedOpinion[]; offset: number; sentiment: SentenceSentimentLabel; diff --git a/sdk/textanalytics/ai-text-analytics/src/analyzeSentimentResult.ts b/sdk/textanalytics/ai-text-analytics/src/analyzeSentimentResult.ts index 30b76d6d9ce2..f5f6d020917c 100644 --- a/sdk/textanalytics/ai-text-analytics/src/analyzeSentimentResult.ts +++ b/sdk/textanalytics/ai-text-analytics/src/analyzeSentimentResult.ts @@ -67,10 +67,6 @@ export interface SentenceSentiment { * The sentence text offset from the start of the document. */ offset: number; - /** - * The length of the sentence text. - */ - length: number; /** * The list of opinions mined from this sentence. For example in "The food is * good, but the service is bad", we would mind these two opinions "food is @@ -106,10 +102,6 @@ export interface AspectSentiment { * The aspect text offset from the start of the sentence. */ offset: number; - /** - * The length of the aspect text. - */ - length: number; } /** @@ -182,7 +174,6 @@ function convertGeneratedSentenceSentiment( confidenceScores: sentence.confidenceScores, sentiment: sentence.sentiment, text: sentence.text, - length: sentence.length, offset: sentence.offset, minedOpinions: sentence.aspects ? sentence.aspects.map( @@ -191,8 +182,7 @@ function convertGeneratedSentenceSentiment( confidenceScores: aspect.confidenceScores, sentiment: aspect.sentiment, text: aspect.text, - offset: aspect.offset, - length: aspect.length + offset: aspect.offset }, opinions: aspect.relations .filter((relation) => relation.relationType === "opinion") diff --git a/sdk/textanalytics/ai-text-analytics/src/generated/generatedClientContext.ts b/sdk/textanalytics/ai-text-analytics/src/generated/generatedClientContext.ts index 97e3f6e65aa8..bb3428009b9e 100644 --- a/sdk/textanalytics/ai-text-analytics/src/generated/generatedClientContext.ts +++ b/sdk/textanalytics/ai-text-analytics/src/generated/generatedClientContext.ts @@ -10,7 +10,7 @@ import * as coreHttp from "@azure/core-http"; import { GeneratedClientOptionalParams } from "./models"; const packageName = "@azure/ai-text-analytics"; -const packageVersion = "5.1.0-beta.2"; +const packageVersion = "5.1.0-beta.1"; export class GeneratedClientContext extends coreHttp.ServiceClient { endpoint: string; diff --git a/sdk/textanalytics/ai-text-analytics/src/generated/models/index.ts b/sdk/textanalytics/ai-text-analytics/src/generated/models/index.ts index 41b9a7b2f383..ed4efe6faf9a 100644 --- a/sdk/textanalytics/ai-text-analytics/src/generated/models/index.ts +++ b/sdk/textanalytics/ai-text-analytics/src/generated/models/index.ts @@ -94,10 +94,6 @@ export interface Entity { * Start position for the entity text. */ offset: number; - /** - * Length for the entity text. - */ - length: number; /** * Confidence score between 0 and 1 of the extracted entity. */ @@ -348,10 +344,6 @@ export interface Match { * Start position for the entity match text. */ offset: number; - /** - * Length for the entity match text. - */ - length: number; } export interface KeyPhraseResult { @@ -539,10 +531,6 @@ export interface SentenceSentiment { * The sentence offset from the start of the document. */ offset: number; - /** - * The length of the sentence. - */ - length: number; /** * The array of aspect object for the sentence. */ @@ -566,10 +554,6 @@ export interface SentenceAspect { * The aspect offset from the start of the sentence. */ offset: number; - /** - * The length of the aspect. - */ - length: number; /** * The aspect text detected. */ @@ -612,10 +596,6 @@ export interface SentenceOpinion { * The opinion offset from the start of the sentence. */ offset: number; - /** - * The length of the opinion. - */ - length: number; /** * The aspect text detected. */ diff --git a/sdk/textanalytics/ai-text-analytics/src/generated/models/mappers.ts b/sdk/textanalytics/ai-text-analytics/src/generated/models/mappers.ts index 23f8ebba9b00..d43b4b9e7def 100644 --- a/sdk/textanalytics/ai-text-analytics/src/generated/models/mappers.ts +++ b/sdk/textanalytics/ai-text-analytics/src/generated/models/mappers.ts @@ -170,13 +170,6 @@ export const Entity: coreHttp.CompositeMapper = { name: "Number" } }, - length: { - serializedName: "length", - required: true, - type: { - name: "Number" - } - }, confidenceScore: { serializedName: "confidenceScore", required: true, @@ -651,13 +644,6 @@ export const Match: coreHttp.CompositeMapper = { type: { name: "Number" } - }, - length: { - serializedName: "length", - required: true, - type: { - name: "Number" - } } } } @@ -1067,13 +1053,6 @@ export const SentenceSentiment: coreHttp.CompositeMapper = { name: "Number" } }, - length: { - serializedName: "length", - required: true, - type: { - name: "Number" - } - }, aspects: { serializedName: "aspects", type: { @@ -1119,13 +1098,6 @@ export const SentenceAspect: coreHttp.CompositeMapper = { name: "Number" } }, - length: { - serializedName: "length", - required: true, - type: { - name: "Number" - } - }, text: { serializedName: "text", required: true, @@ -1219,13 +1191,6 @@ export const SentenceOpinion: coreHttp.CompositeMapper = { name: "Number" } }, - length: { - serializedName: "length", - required: true, - type: { - name: "Number" - } - }, text: { serializedName: "text", required: true, diff --git a/sdk/textanalytics/ai-text-analytics/swagger/README.md b/sdk/textanalytics/ai-text-analytics/swagger/README.md index b6934064ef4c..fa9a980f541b 100644 --- a/sdk/textanalytics/ai-text-analytics/swagger/README.md +++ b/sdk/textanalytics/ai-text-analytics/swagger/README.md @@ -155,6 +155,18 @@ directive: $["x-ms-client-name"] = "dataSourceEntityId"; ``` +### Remove Entity/Match offset/length + +```yaml +directive: + - from: swagger-document + where: $.definitions..properties + transform: > + if ($.length !== undefined) { + $.length = undefined; + } +``` + ### Rename SentimentConfidenceScorePerLabel -> SentimentConfidenceScores ```yaml diff --git a/sdk/textanalytics/ai-text-analytics/test/collections.spec.ts b/sdk/textanalytics/ai-text-analytics/test/collections.spec.ts index 4599319f87d6..379237bf98ae 100644 --- a/sdk/textanalytics/ai-text-analytics/test/collections.spec.ts +++ b/sdk/textanalytics/ai-text-analytics/test/collections.spec.ts @@ -201,7 +201,6 @@ describe("RecognizeCategorizedEntitiesResultArray", () => { text: "Microsoft", category: "Organization", confidenceScore: 0.9989, - length: 0, offset: 0 } ], @@ -215,7 +214,6 @@ describe("RecognizeCategorizedEntitiesResultArray", () => { category: "DateTime", subCategory: "DateRange", confidenceScore: 0.8, - length: 0, offset: 0 } ], @@ -268,7 +266,6 @@ describe("RecognizeLinkedEntitiesResultArray", () => { { text: "Seattle", confidenceScore: 0.15046201222847677, - length: 0, offset: 0 } ], @@ -289,7 +286,6 @@ describe("RecognizeLinkedEntitiesResultArray", () => { { text: "Microsoft", confidenceScore: 0.1869365971673207, - length: 0, offset: 0 } ], @@ -343,7 +339,6 @@ describe("RecognizeLinkedEntitiesResultArray", () => { text: "(555) 555-5555", category: "US Phone Number", confidenceScore: 0.9989, - length: 0, offset: 0 } ], @@ -358,7 +353,6 @@ describe("RecognizeLinkedEntitiesResultArray", () => { category: "US Address", subCategory: "", confidenceScore: 0.8, - length: 0, offset: 0 } ], diff --git a/sdk/textanalytics/ai-text-analytics/test/textAnalyticsClient.spec.ts b/sdk/textanalytics/ai-text-analytics/test/textAnalyticsClient.spec.ts index 8e8d1aea6056..49102aee448d 100644 --- a/sdk/textanalytics/ai-text-analytics/test/textAnalyticsClient.spec.ts +++ b/sdk/textanalytics/ai-text-analytics/test/textAnalyticsClient.spec.ts @@ -185,7 +185,7 @@ describe("[AAD] TextAnalyticsClient", function() { assert.isAtLeast(aspect.confidenceScores.positive, 0); assert.isAtLeast(aspect.confidenceScores.negative, 0); assert.equal(aspect.offset, 32); - assert.equal(aspect.length, 6); + assert.equal(aspect.text.length, 6); const sleekOpinion = opinion.opinions[0]; assert.equal("sleek", sleekOpinion.text); @@ -194,7 +194,7 @@ describe("[AAD] TextAnalyticsClient", function() { assert.isAtLeast(sleekOpinion.confidenceScores.positive, 0); assert.isFalse(sleekOpinion.isNegated); assert.equal(sleekOpinion.offset, 9); - assert.equal(sleekOpinion.length, 5); + assert.equal(sleekOpinion.text.length, 5); const premiumOpinion = opinion.opinions[1]; assert.equal("premium", premiumOpinion.text); @@ -203,7 +203,7 @@ describe("[AAD] TextAnalyticsClient", function() { assert.isAtLeast(premiumOpinion.confidenceScores.positive, 0); assert.isFalse(premiumOpinion.isNegated); assert.equal(premiumOpinion.offset, 15); - assert.equal(premiumOpinion.length, 7); + assert.equal(premiumOpinion.text.length, 7); }) ); }); @@ -679,7 +679,7 @@ describe("[AAD] TextAnalyticsClient", function() { ]); if (!result.error) { assert.equal(result.entities[0].offset, 8); - assert.equal(result.entities[0].length, 11); + assert.equal(result.entities[0].text.length, 11); } }); @@ -689,7 +689,7 @@ describe("[AAD] TextAnalyticsClient", function() { ]); if (!result.error) { assert.equal(result.entities[0].offset, 10); - assert.equal(result.entities[0].length, 11); + assert.equal(result.entities[0].text.length, 11); } }); @@ -699,7 +699,7 @@ describe("[AAD] TextAnalyticsClient", function() { ]); if (!result.error) { assert.equal(result.entities[0].offset, 17); - assert.equal(result.entities[0].length, 11); + assert.equal(result.entities[0].text.length, 11); } }); @@ -709,7 +709,7 @@ describe("[AAD] TextAnalyticsClient", function() { ]); if (!result.error) { assert.equal(result.entities[0].offset, 25); - assert.equal(result.entities[0].length, 11); + assert.equal(result.entities[0].text.length, 11); } }); @@ -719,7 +719,7 @@ describe("[AAD] TextAnalyticsClient", function() { ]); if (!result.error) { assert.equal(result.entities[0].offset, 9); - assert.equal(result.entities[0].length, 11); + assert.equal(result.entities[0].text.length, 11); } }); @@ -729,7 +729,7 @@ describe("[AAD] TextAnalyticsClient", function() { ]); if (!result.error) { assert.equal(result.entities[0].offset, 10); - assert.equal(result.entities[0].length, 11); + assert.equal(result.entities[0].text.length, 11); } }); @@ -739,7 +739,7 @@ describe("[AAD] TextAnalyticsClient", function() { ]); if (!result.error) { assert.equal(result.entities[0].offset, 8); - assert.equal(result.entities[0].length, 11); + assert.equal(result.entities[0].text.length, 11); } }); @@ -749,7 +749,7 @@ describe("[AAD] TextAnalyticsClient", function() { ]); if (!result.error) { assert.equal(result.entities[0].offset, 8); - assert.equal(result.entities[0].length, 11); + assert.equal(result.entities[0].text.length, 11); } }); @@ -759,7 +759,7 @@ describe("[AAD] TextAnalyticsClient", function() { ]); if (!result.error) { assert.equal(result.entities[0].offset, 121); - assert.equal(result.entities[0].length, 11); + assert.equal(result.entities[0].text.length, 11); } }); }); From d06a0350432231ca049a78c89b93c1bb9fa33119 Mon Sep 17 00:00:00 2001 From: deyaaeldeen Date: Mon, 28 Sep 2020 15:30:53 -0400 Subject: [PATCH 2/4] formatting --- sdk/textanalytics/ai-text-analytics/swagger/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sdk/textanalytics/ai-text-analytics/swagger/README.md b/sdk/textanalytics/ai-text-analytics/swagger/README.md index fa9a980f541b..ab7c4b880f9a 100644 --- a/sdk/textanalytics/ai-text-analytics/swagger/README.md +++ b/sdk/textanalytics/ai-text-analytics/swagger/README.md @@ -92,7 +92,7 @@ directive: - from: swagger-document where: $.definitions.DocumentStatistics transform: > - $["x-ms-client-name"] = "TextDocumentStatistics"; + $["x-ms-client-name"] = "TextDocumentStatistics"; ``` ### RequestStatistics => TextDocumentBatchStatistics @@ -102,7 +102,7 @@ directive: - from: swagger-document where: $.definitions.RequestStatistics transform: > - $["x-ms-client-name"] = "TextDocumentBatchStatistics"; + $["x-ms-client-name"] = "TextDocumentBatchStatistics"; ``` ### Rename showStats -> includeStatistics @@ -121,7 +121,7 @@ directive: } ``` -### Rename {Document,Sentence}SentimentValue -> Label +### Rename {Document,Sentence}SentimentValue -> Label ```yaml directive: @@ -174,7 +174,7 @@ directive: - from: swagger-document where: $.definitions.SentimentConfidenceScorePerLabel transform: > - $["x-ms-client-name"] = "SentimentConfidenceScores"; + $["x-ms-client-name"] = "SentimentConfidenceScores"; ``` ### Change some casing to use camelCase From f42be1ad221e37112ac59f0019d4cbaef3f79efa Mon Sep 17 00:00:00 2001 From: deyaaeldeen Date: Mon, 28 Sep 2020 16:03:35 -0400 Subject: [PATCH 3/4] adding an entry to the changelog --- sdk/textanalytics/ai-text-analytics/CHANGELOG.md | 3 ++- .../ai-text-analytics/src/generated/generatedClientContext.ts | 2 +- sdk/textanalytics/ai-text-analytics/swagger/README.md | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/sdk/textanalytics/ai-text-analytics/CHANGELOG.md b/sdk/textanalytics/ai-text-analytics/CHANGELOG.md index 9b1c850534d6..44eace08d095 100644 --- a/sdk/textanalytics/ai-text-analytics/CHANGELOG.md +++ b/sdk/textanalytics/ai-text-analytics/CHANGELOG.md @@ -1,7 +1,8 @@ # Release History -## 5.1.0-beta.2 (Unreleased) +## 5.1.0-beta.2 (2020-10-02) +- The `length` property is removed from `SentenceSentiment`, `Entity`, `Match`, PiiEntity`, and`CategorizedEntity` because the length information can be accessed from the text property itself using the string's length property. ## 5.1.0-beta.1 (2020-09-17) diff --git a/sdk/textanalytics/ai-text-analytics/src/generated/generatedClientContext.ts b/sdk/textanalytics/ai-text-analytics/src/generated/generatedClientContext.ts index bb3428009b9e..97e3f6e65aa8 100644 --- a/sdk/textanalytics/ai-text-analytics/src/generated/generatedClientContext.ts +++ b/sdk/textanalytics/ai-text-analytics/src/generated/generatedClientContext.ts @@ -10,7 +10,7 @@ import * as coreHttp from "@azure/core-http"; import { GeneratedClientOptionalParams } from "./models"; const packageName = "@azure/ai-text-analytics"; -const packageVersion = "5.1.0-beta.1"; +const packageVersion = "5.1.0-beta.2"; export class GeneratedClientContext extends coreHttp.ServiceClient { endpoint: string; diff --git a/sdk/textanalytics/ai-text-analytics/swagger/README.md b/sdk/textanalytics/ai-text-analytics/swagger/README.md index ab7c4b880f9a..40e7457032f5 100644 --- a/sdk/textanalytics/ai-text-analytics/swagger/README.md +++ b/sdk/textanalytics/ai-text-analytics/swagger/README.md @@ -14,7 +14,7 @@ output-folder: ../ source-code-folder-path: ./src/generated input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/cognitiveservices/data-plane/TextAnalytics/preview/v3.1-preview.2/TextAnalytics.json add-credentials: false -package-version: 5.1.0-beta.1 +package-version: 5.1.0-beta.2 v3: true use-extension: "@autorest/typescript": "6.0.0-dev.20200618.1" From c43b3caa737cc78160116ffc357b6487b68229f9 Mon Sep 17 00:00:00 2001 From: deyaaeldeen Date: Mon, 28 Sep 2020 16:35:03 -0400 Subject: [PATCH 4/4] revert release date --- sdk/textanalytics/ai-text-analytics/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/textanalytics/ai-text-analytics/CHANGELOG.md b/sdk/textanalytics/ai-text-analytics/CHANGELOG.md index 44eace08d095..8193c5bc6c3a 100644 --- a/sdk/textanalytics/ai-text-analytics/CHANGELOG.md +++ b/sdk/textanalytics/ai-text-analytics/CHANGELOG.md @@ -1,6 +1,6 @@ # Release History -## 5.1.0-beta.2 (2020-10-02) +## 5.1.0-beta.2 (unreleased) - The `length` property is removed from `SentenceSentiment`, `Entity`, `Match`, PiiEntity`, and`CategorizedEntity` because the length information can be accessed from the text property itself using the string's length property.