From 6476f73d5f8355c63169cbcc12c64a934818bb9f Mon Sep 17 00:00:00 2001 From: shafang Date: Fri, 28 Aug 2020 16:52:54 -0700 Subject: [PATCH 1/2] add offset and length for sentimentSentiment --- .../azure-ai-textanalytics/CHANGELOG.md | 2 +- .../AnalyzeSentimentAsyncClient.java | 7 +-- .../RecognizeLinkedEntityAsyncClient.java | 2 +- .../models/CategorizedEntity.java | 28 +++++----- .../models/LinkedEntityMatch.java | 34 ++++++------ .../ai/textanalytics/models/PiiEntity.java | 2 +- .../models/SentenceSentiment.java | 52 ++++++++++++++----- .../com/azure/ai/textanalytics/TestUtils.java | 21 +++++--- .../TextAnalyticsAsyncClientTest.java | 4 +- .../TextAnalyticsClientTest.java | 4 +- .../TextAnalyticsClientTestBase.java | 3 ++ 11 files changed, 99 insertions(+), 60 deletions(-) diff --git a/sdk/textanalytics/azure-ai-textanalytics/CHANGELOG.md b/sdk/textanalytics/azure-ai-textanalytics/CHANGELOG.md index c2f904541e273..c083a82b5be12 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/CHANGELOG.md +++ b/sdk/textanalytics/azure-ai-textanalytics/CHANGELOG.md @@ -1,6 +1,6 @@ # Release History ## 5.1.0-beta.1 (Unreleased) -- Added `offset` and `length` properties for `CategorizedEntity` and `LinkedEntityMatch`. +- Added `offset` and `length` properties for `CategorizedEntity`, `LinkedEntityMatch` and `SentenceSentiment` - `length` is the number of characters in the text of these models - `offset` is the offset of the text from the start of the document diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/AnalyzeSentimentAsyncClient.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/AnalyzeSentimentAsyncClient.java index 176c441ec8478..7423d2d107e4f 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/AnalyzeSentimentAsyncClient.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/AnalyzeSentimentAsyncClient.java @@ -44,7 +44,6 @@ import static com.azure.ai.textanalytics.TextAnalyticsAsyncClient.COGNITIVE_TRACING_NAMESPACE_VALUE; import static com.azure.ai.textanalytics.implementation.Utility.inputDocumentsValidation; -import static com.azure.ai.textanalytics.implementation.Utility.mapToHttpResponseExceptionIfExist; import static com.azure.ai.textanalytics.implementation.Utility.toBatchStatistics; import static com.azure.ai.textanalytics.implementation.Utility.toMultiLanguageInput; import static com.azure.ai.textanalytics.implementation.Utility.toTextAnalyticsError; @@ -160,9 +159,11 @@ private AnalyzeSentimentResult convertToAnalyzeSentimentResult(DocumentSentiment final SentenceSentimentValue sentenceSentimentValue = sentenceSentiment.getSentiment(); return new SentenceSentiment(sentenceSentiment.getText(), TextSentiment.fromString(sentenceSentimentValue == null ? null : sentenceSentimentValue.toString()), - toMinedOpinionList(sentenceSentiment, documentSentimentList), new SentimentConfidenceScores(confidenceScorePerSentence.getNegative(), - confidenceScorePerSentence.getNeutral(), confidenceScorePerSentence.getPositive()) + confidenceScorePerSentence.getNeutral(), confidenceScorePerSentence.getPositive()), + toMinedOpinionList(sentenceSentiment, documentSentimentList), + sentenceSentiment.getOffset(), + sentenceSentiment.getLength() ); }).collect(Collectors.toList()); diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/RecognizeLinkedEntityAsyncClient.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/RecognizeLinkedEntityAsyncClient.java index 500c5a769897b..d0b2e6b176c27 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/RecognizeLinkedEntityAsyncClient.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/RecognizeLinkedEntityAsyncClient.java @@ -178,7 +178,7 @@ private IterableStream mapLinkedEntity( linkedEntitiesList.add(new LinkedEntity( linkedEntity.getName(), new IterableStream<>(linkedEntity.getMatches().stream().map(match -> new LinkedEntityMatch( - match.getText(), match.getOffset(), match.getLength(), match.getConfidenceScore())) + match.getText(), match.getConfidenceScore(), match.getOffset(), match.getLength())) .collect(Collectors.toList())), linkedEntity.getLanguage(), linkedEntity.getId(), linkedEntity.getUrl(), linkedEntity.getDataSource())); diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/CategorizedEntity.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/CategorizedEntity.java index ac8e3566c83f8..632785bc4f746 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/CategorizedEntity.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/CategorizedEntity.java @@ -25,6 +25,11 @@ public final class CategorizedEntity { */ private final String subcategory; + /* + * Confidence score between 0 and 1 of the extracted entity. + */ + private final double confidenceScore; + /* * Start position for the entity text. */ @@ -35,11 +40,6 @@ public final class CategorizedEntity { */ private final int length; - /* - * Confidence score between 0 and 1 of the extracted entity. - */ - private final double confidenceScore; - /** * Creates a {@link CategorizedEntity} model that describes entity. * @@ -103,6 +103,15 @@ public String getSubcategory() { return this.subcategory; } + /** + * Get the score property: Confidence score between 0 and 1 of the extracted entity. + * + * @return The score value. + */ + public double getConfidenceScore() { + return this.confidenceScore; + } + /** * Get the offset of entity text. * @@ -120,13 +129,4 @@ public int getOffset() { public int getLength() { return length; } - - /** - * Get the score property: Confidence score between 0 and 1 of the extracted entity. - * - * @return The score value. - */ - public double getConfidenceScore() { - return this.confidenceScore; - } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/LinkedEntityMatch.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/LinkedEntityMatch.java index fee189c271386..83ac522b84e18 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/LinkedEntityMatch.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/LinkedEntityMatch.java @@ -11,15 +11,15 @@ @Immutable public final class LinkedEntityMatch { /* - * If a well-known item is recognized, a decimal number denoting the - * confidence level between 0 and 1 will be returned. + * Linked entity match text as appears in the request. */ - private final double confidenceScore; + private final String text; /* - * Linked entity match text as appears in the request. + * If a well-known item is recognized, a decimal number denoting the + * confidence level between 0 and 1 will be returned. */ - private final String text; + private final double confidenceScore; /* * Start position for the linked entity match text. @@ -49,12 +49,12 @@ public LinkedEntityMatch(String text, double confidenceScore) { * Creates a {@link LinkedEntityMatch} model that describes linked entity match. * * @param text The entity text as appears in the request. - * @param offset The start position for the entity text. - * @param length The length for the entity text. * @param confidenceScore If a well-known item is recognized, a decimal number denoting the * confidence level between 0 and 1 will be returned. + * @param offset The start position for the entity text. + * @param length The length for the entity text. */ - public LinkedEntityMatch(String text, int offset, int length, double confidenceScore) { + public LinkedEntityMatch(String text, double confidenceScore, int offset, int length) { this.text = text; this.offset = offset; this.length = length; @@ -62,22 +62,22 @@ public LinkedEntityMatch(String text, int offset, int length, double confidenceS } /** - * Get the score property: If a well-known item is recognized, a decimal - * number denoting the confidence level between 0 and 1 will be returned. + * Get the linked entity match text property: Entity text as appears in the request. * - * @return The score value. + * @return The text value. */ - public double getConfidenceScore() { - return this.confidenceScore; + public String getText() { + return this.text; } /** - * Get the linked entity match text property: Entity text as appears in the request. + * Get the score property: If a well-known item is recognized, a decimal + * number denoting the confidence level between 0 and 1 will be returned. * - * @return The text value. + * @return The score value. */ - public String getText() { - return this.text; + public double getConfidenceScore() { + return this.confidenceScore; } /** diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/PiiEntity.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/PiiEntity.java index 626f79204590a..839fb46cf2764 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/PiiEntity.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/PiiEntity.java @@ -55,9 +55,9 @@ public PiiEntity(String text, EntityCategory category, String subcategory, doubl this.text = text; this.category = category; this.subcategory = subcategory; + this.confidenceScore = confidenceScore; this.offset = offset; this.length = length; - this.confidenceScore = confidenceScore; } /** diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/SentenceSentiment.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/SentenceSentiment.java index 67c550c41d5c7..ab84eb2735e2a 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/SentenceSentiment.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/SentenceSentiment.java @@ -13,39 +13,49 @@ @Immutable public final class SentenceSentiment { private final String text; - private final SentimentConfidenceScores confidenceScores; private final TextSentiment sentiment; + private final SentimentConfidenceScores confidenceScores; private final IterableStream minedOpinions; + private final int offset; + private final int length; /** * Creates a {@link SentenceSentiment} model that describes the sentiment analysis of sentence. + * * @param text The sentence text. * @param sentiment The sentiment label of the sentence. * @param confidenceScores The sentiment confidence score (Softmax score) between 0 and 1, for each sentiment label. - * Higher values signify higher confidence. + * Higher values signify higher confidence. */ public SentenceSentiment(String text, TextSentiment sentiment, SentimentConfidenceScores confidenceScores) { this.text = text; this.sentiment = sentiment; - this.minedOpinions = null; this.confidenceScores = confidenceScores; + this.minedOpinions = null; + this.offset = 0; + this.length = 0; } /** * Creates a {@link SentenceSentiment} model that describes the sentiment analysis of sentence. + * * @param text The sentence text. * @param sentiment The sentiment label of the sentence. + * @param confidenceScores The sentiment confidence score (Softmax score) between 0 and 1, for each sentiment label. + * Higher values signify higher confidence. * @param minedOpinions The mined opinions of the sentence sentiment. This is only returned if you pass the * opinion mining parameter to the analyze sentiment APIs. - * @param confidenceScores The sentiment confidence score (Softmax score) between 0 and 1, for each sentiment label. - * Higher values signify higher confidence. + * @param offset The start position for the entity text. + * @param length The length for the entity text. */ - public SentenceSentiment(String text, TextSentiment sentiment, IterableStream minedOpinions, - SentimentConfidenceScores confidenceScores) { + public SentenceSentiment(String text, TextSentiment sentiment, SentimentConfidenceScores confidenceScores, + IterableStream minedOpinions, int offset, int length) { this.text = text; this.sentiment = sentiment; this.minedOpinions = minedOpinions; this.confidenceScores = confidenceScores; + this.offset = offset; + this.length = length; } /** @@ -66,6 +76,16 @@ public TextSentiment getSentiment() { return sentiment; } + /** + * Get the confidence score of the sentiment label. All score values sum up to 1, the higher the score, the + * higher the confidence in the sentiment. + * + * @return The {@link SentimentConfidenceScores}. + */ + public SentimentConfidenceScores getConfidenceScores() { + return confidenceScores; + } + /** * Get the mined opinions of sentence sentiment. * This is only returned if you pass the opinion mining parameter to the analyze sentiment APIs. @@ -77,12 +97,20 @@ public IterableStream getMinedOpinions() { } /** - * Get the confidence score of the sentiment label. All score values sum up to 1, the higher the score, the - * higher the confidence in the sentiment. + * Get the offset of sentence sentiment match text. * - * @return The {@link SentimentConfidenceScores}. + * @return The offset of sentence sentiment match text. */ - public SentimentConfidenceScores getConfidenceScores() { - return confidenceScores; + public int getOffset() { + return offset; + } + + /** + * Get the length of sentence sentiment match text. + * + * @return The length of sentence sentiment match text. + */ + public int getLength() { + return length; } } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/test/java/com/azure/ai/textanalytics/TestUtils.java b/sdk/textanalytics/azure-ai-textanalytics/src/test/java/com/azure/ai/textanalytics/TestUtils.java index f364077e39e69..fdb82da76b261 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/test/java/com/azure/ai/textanalytics/TestUtils.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/test/java/com/azure/ai/textanalytics/TestUtils.java @@ -283,7 +283,7 @@ static RecognizeLinkedEntitiesResultCollection getExpectedBatchLinkedEntities() * Helper method to get the expected linked Entities List 1 */ static List getLinkedEntitiesList1() { - final LinkedEntityMatch linkedEntityMatch = new LinkedEntityMatch("Seattle", 26, 7, 0.0); + final LinkedEntityMatch linkedEntityMatch = new LinkedEntityMatch("Seattle", 0.0, 26, 7); LinkedEntity linkedEntity = new LinkedEntity( "Seattle", new IterableStream<>(Collections.singletonList(linkedEntityMatch)), "en", "Seattle", "https://en.wikipedia.org/wiki/Seattle", @@ -295,7 +295,7 @@ static List getLinkedEntitiesList1() { * Helper method to get the expected linked Entities List 2 */ static List getLinkedEntitiesList2() { - LinkedEntityMatch linkedEntityMatch = new LinkedEntityMatch("Microsoft", 10, 9, 0.0); + LinkedEntityMatch linkedEntityMatch = new LinkedEntityMatch("Microsoft", 0.0, 10, 9); LinkedEntity linkedEntity = new LinkedEntity( "Microsoft", new IterableStream<>(Collections.singletonList(linkedEntityMatch)), "en", "Microsoft", "https://en.wikipedia.org/wiki/Microsoft", @@ -342,20 +342,24 @@ static DocumentSentiment getExpectedDocumentSentiment() { new SentimentConfidenceScores(0.0, 0.0, 0.0), new IterableStream<>(asList( new SentenceSentiment("The hotel was dark and unclean.", TextSentiment.NEGATIVE, + new SentimentConfidenceScores(0.0, 0.0, 0.0), new IterableStream<>(asList(new MinedOpinion( new AspectSentiment("hotel", TextSentiment.NEGATIVE, 4, 5, new SentimentConfidenceScores(0.0, 0.0, 0.0)), new IterableStream<>(asList( new OpinionSentiment("dark", TextSentiment.NEGATIVE, 14, 4, false, new SentimentConfidenceScores(0.0, 0.0, 0.0)), new OpinionSentiment("unclean", TextSentiment.NEGATIVE, 23, 7, false, new SentimentConfidenceScores(0.0, 0.0, 0.0)) ))))), - new SentimentConfidenceScores(0.0, 0.0, 0.0)), + 0, 31 + ), new SentenceSentiment("The restaurant had amazing gnocchi.", TextSentiment.POSITIVE, + new SentimentConfidenceScores(0.0, 0.0, 0.0), new IterableStream<>(asList(new MinedOpinion( new AspectSentiment("gnocchi", TextSentiment.POSITIVE, 59, 7, new SentimentConfidenceScores(0.0, 0.0, 0.0)), new IterableStream<>(asList( new OpinionSentiment("amazing", TextSentiment.POSITIVE, 51, 7, false, new SentimentConfidenceScores(0.0, 0.0, 0.0)) ))))), - new SentimentConfidenceScores(0.0, 0.0, 0.0)) + 32, 35 + ) )), null); } @@ -367,20 +371,23 @@ static DocumentSentiment getExpectedDocumentSentiment2() { new SentimentConfidenceScores(0.0, 0.0, 0.0), new IterableStream<>(asList( new SentenceSentiment("The restaurant had amazing gnocchi.", TextSentiment.POSITIVE, + new SentimentConfidenceScores(0.0, 0.0, 0.0), new IterableStream<>(asList(new MinedOpinion( new AspectSentiment("gnocchi", TextSentiment.POSITIVE, 27, 7, new SentimentConfidenceScores(0.0, 0.0, 0.0)), new IterableStream<>(asList( new OpinionSentiment("amazing", TextSentiment.POSITIVE, 19, 7, false, new SentimentConfidenceScores(0.0, 0.0, 0.0)) ))))), - new SentimentConfidenceScores(0.0, 0.0, 0.0)), + 0, 35 + ), new SentenceSentiment("The hotel was dark and unclean.", TextSentiment.NEGATIVE, - new IterableStream<>(asList(new MinedOpinion( + new SentimentConfidenceScores(0.0, 0.0, 0.0), new IterableStream<>(asList(new MinedOpinion( new AspectSentiment("hotel", TextSentiment.NEGATIVE, 40, 5, new SentimentConfidenceScores(0.0, 0.0, 0.0)), new IterableStream<>(asList( new OpinionSentiment("dark", TextSentiment.NEGATIVE, 50, 4, false, new SentimentConfidenceScores(0.0, 0.0, 0.0)), new OpinionSentiment("unclean", TextSentiment.NEGATIVE, 59, 7, false, new SentimentConfidenceScores(0.0, 0.0, 0.0)) ))))), - new SentimentConfidenceScores(0.0, 0.0, 0.0)) + 36, 31 + ) )), null); } diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/test/java/com/azure/ai/textanalytics/TextAnalyticsAsyncClientTest.java b/sdk/textanalytics/azure-ai-textanalytics/src/test/java/com/azure/ai/textanalytics/TextAnalyticsAsyncClientTest.java index 6c04ff9158fc5..b2653227b10a3 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/test/java/com/azure/ai/textanalytics/TextAnalyticsAsyncClientTest.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/test/java/com/azure/ai/textanalytics/TextAnalyticsAsyncClientTest.java @@ -857,8 +857,8 @@ public void analyzeSentimentForFaultyText(HttpClient httpClient, TextAnalyticsSe TextSentiment.NEUTRAL, new SentimentConfidenceScores(0.0, 0.0, 0.0), new IterableStream<>(Arrays.asList( - new SentenceSentiment("!", TextSentiment.NEUTRAL, null, new SentimentConfidenceScores(0.0, 0.0, 0.0)), - new SentenceSentiment("@#%%", TextSentiment.NEUTRAL, null, new SentimentConfidenceScores(0.0, 0.0, 0.0)) + new SentenceSentiment("!", TextSentiment.NEUTRAL, new SentimentConfidenceScores(0.0, 0.0, 0.0), null, 0, 1), + new SentenceSentiment("@#%%", TextSentiment.NEUTRAL, new SentimentConfidenceScores(0.0, 0.0, 0.0), null, 1, 4) )), null); StepVerifier.create(client.analyzeSentiment(input)) .assertNext(response -> validateAnalyzedSentiment(false, expectedDocumentSentiment, response)) diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/test/java/com/azure/ai/textanalytics/TextAnalyticsClientTest.java b/sdk/textanalytics/azure-ai-textanalytics/src/test/java/com/azure/ai/textanalytics/TextAnalyticsClientTest.java index fc573227a3423..edad61d208b73 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/test/java/com/azure/ai/textanalytics/TextAnalyticsClientTest.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/test/java/com/azure/ai/textanalytics/TextAnalyticsClientTest.java @@ -790,8 +790,8 @@ public void analyzeSentimentForFaultyText(HttpClient httpClient, TextAnalyticsSe TextSentiment.NEUTRAL, new SentimentConfidenceScores(0.0, 0.0, 0.0), new IterableStream<>(Arrays.asList( - new SentenceSentiment("!", TextSentiment.NEUTRAL, null, new SentimentConfidenceScores(0.0, 0.0, 0.0)), - new SentenceSentiment("@#%%", TextSentiment.NEUTRAL, null, new SentimentConfidenceScores(0.0, 0.0, 0.0)) + new SentenceSentiment("!", TextSentiment.NEUTRAL, new SentimentConfidenceScores(0.0, 0.0, 0.0), null, 0, 1), + new SentenceSentiment("@#%%", TextSentiment.NEUTRAL, new SentimentConfidenceScores(0.0, 0.0, 0.0), null, 1, 4) )), null); validateAnalyzedSentiment(false, expectedDocumentSentiment, client.analyzeSentiment(input)); }); diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/test/java/com/azure/ai/textanalytics/TextAnalyticsClientTestBase.java b/sdk/textanalytics/azure-ai-textanalytics/src/test/java/com/azure/ai/textanalytics/TextAnalyticsClientTestBase.java index 8ae36b15d0b5b..dc7225f499fe1 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/test/java/com/azure/ai/textanalytics/TextAnalyticsClientTestBase.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/test/java/com/azure/ai/textanalytics/TextAnalyticsClientTestBase.java @@ -817,6 +817,9 @@ static void validateAnalyzedSentenceSentiment(boolean includeOpinionMining, List static void validateSentenceSentiment(boolean includeOpinionMining, SentenceSentiment expectedSentiment, SentenceSentiment actualSentiment) { assertEquals(expectedSentiment.getSentiment(), actualSentiment.getSentiment()); assertEquals(expectedSentiment.getText(), actualSentiment.getText()); + assertEquals(expectedSentiment.getOffset(), actualSentiment.getOffset()); + assertEquals(expectedSentiment.getLength(), actualSentiment.getLength()); + if (includeOpinionMining) { validateSentenceMinedOpinions(expectedSentiment.getMinedOpinions().stream().collect(Collectors.toList()), actualSentiment.getMinedOpinions().stream().collect(Collectors.toList())); From 8f914029e29ac9d387803cc94f8db120ed7fcaba Mon Sep 17 00:00:00 2001 From: shafang Date: Sun, 30 Aug 2020 21:17:13 -0700 Subject: [PATCH 2/2] review javadoc and make them consistency --- .../models/CategorizedEntity.java | 35 +++++-------------- .../models/LinkedEntityMatch.java | 28 ++++----------- .../models/SentenceSentiment.java | 18 +++++----- 3 files changed, 23 insertions(+), 58 deletions(-) diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/CategorizedEntity.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/CategorizedEntity.java index 632785bc4f746..3eecf35853b48 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/CategorizedEntity.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/CategorizedEntity.java @@ -10,34 +10,11 @@ */ @Immutable public final class CategorizedEntity { - /* - * CategorizedEntity text as appears in the request. - */ private final String text; - - /* - * CategorizedEntity category, such as Person/Location/Org/SSN etc. - */ private final EntityCategory category; - - /* - * CategorizedEntity sub category, such as Age/Year/TimeRange etc. - */ private final String subcategory; - - /* - * Confidence score between 0 and 1 of the extracted entity. - */ private final double confidenceScore; - - /* - * Start position for the entity text. - */ private final int offset; - - /* - * Length for the entity text. - */ private final int length; /** @@ -46,7 +23,8 @@ public final class CategorizedEntity { * @param text The entity text as appears in the request. * @param category The entity category, such as Person/Location/Org/SSN etc. * @param subcategory The entity subcategory, such as Age/Year/TimeRange etc. - * @param confidenceScore A confidence score between 0 and 1 of the extracted entity. + * @param confidenceScore If a well-known item is recognized, a decimal number denoting the confidence level + * between 0 and 1 will be returned. */ public CategorizedEntity(String text, EntityCategory category, String subcategory, double confidenceScore) { this.text = text; @@ -59,10 +37,12 @@ public CategorizedEntity(String text, EntityCategory category, String subcategor /** * Creates a {@link CategorizedEntity} model that describes entity. + * * @param text The entity text as appears in the request. * @param category The entity category, such as Person/Location/Org/SSN etc. * @param subcategory The entity subcategory, such as Age/Year/TimeRange etc. - * @param confidenceScore A confidence score between 0 and 1 of the extracted entity. + * @param confidenceScore If a well-known item is recognized, a decimal number denoting the confidence level + * between 0 and 1 will be returned. * @param offset The start position for the entity text. * @param length The length for the entity text. */ @@ -104,7 +84,8 @@ public String getSubcategory() { } /** - * Get the score property: Confidence score between 0 and 1 of the extracted entity. + * Get the score property: If a well-known item is recognized, a decimal + * number denoting the confidence level between 0 and 1 will be returned. * * @return The score value. */ @@ -113,7 +94,7 @@ public double getConfidenceScore() { } /** - * Get the offset of entity text. + * Get the offset of entity text. The start position for the entity text in a document. * * @return The offset of entity text. */ diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/LinkedEntityMatch.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/LinkedEntityMatch.java index 83ac522b84e18..613f64bfdf75d 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/LinkedEntityMatch.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/LinkedEntityMatch.java @@ -10,31 +10,15 @@ */ @Immutable public final class LinkedEntityMatch { - /* - * Linked entity match text as appears in the request. - */ private final String text; - - /* - * If a well-known item is recognized, a decimal number denoting the - * confidence level between 0 and 1 will be returned. - */ private final double confidenceScore; - - /* - * Start position for the linked entity match text. - */ private final int offset; - - /* - * Length for the linked entity match text. - */ private final int length; /** * Creates a {@link LinkedEntityMatch} model that describes linked entity match. * - * @param text The entity text as appears in the request. + * @param text The linked entity match text as appears in the request. * @param confidenceScore If a well-known item is recognized, a decimal number denoting the * confidence level between 0 and 1 will be returned. */ @@ -48,11 +32,11 @@ public LinkedEntityMatch(String text, double confidenceScore) { /** * Creates a {@link LinkedEntityMatch} model that describes linked entity match. * - * @param text The entity text as appears in the request. + * @param text The linked entity match text as appears in the request. * @param confidenceScore If a well-known item is recognized, a decimal number denoting the * confidence level between 0 and 1 will be returned. - * @param offset The start position for the entity text. - * @param length The length for the entity text. + * @param offset The start position for the linked entity match text in a document. + * @param length The length of linked entity match text. */ public LinkedEntityMatch(String text, double confidenceScore, int offset, int length) { this.text = text; @@ -62,7 +46,7 @@ public LinkedEntityMatch(String text, double confidenceScore, int offset, int le } /** - * Get the linked entity match text property: Entity text as appears in the request. + * Get the linked entity match text property: linked entity text as appears in the request. * * @return The text value. */ @@ -81,7 +65,7 @@ public double getConfidenceScore() { } /** - * Get the offset of linked entity match text. + * Get the offset of linked entity match text. The start position for the linked entity match text in a document. * * @return The offset of linked entity match text. */ diff --git a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/SentenceSentiment.java b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/SentenceSentiment.java index ab84eb2735e2a..8f0feafa34853 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/SentenceSentiment.java +++ b/sdk/textanalytics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/SentenceSentiment.java @@ -7,8 +7,8 @@ import com.azure.core.util.IterableStream; /** - * The {@link SentenceSentiment} model that contains a sentiment label of a sentence, confidence score of the - * sentiment label, length of the sentence and offset of the sentence within a document. + * The {@link SentenceSentiment} model that contains a sentiment label of a sentence, confidence scores of the + * sentiment label, mined opinions, offset of sentence, and length of sentence within a document. */ @Immutable public final class SentenceSentiment { @@ -45,8 +45,8 @@ public SentenceSentiment(String text, TextSentiment sentiment, SentimentConfiden * Higher values signify higher confidence. * @param minedOpinions The mined opinions of the sentence sentiment. This is only returned if you pass the * opinion mining parameter to the analyze sentiment APIs. - * @param offset The start position for the entity text. - * @param length The length for the entity text. + * @param offset The start position for the sentence in a document. + * @param length The length of sentence. */ public SentenceSentiment(String text, TextSentiment sentiment, SentimentConfidenceScores confidenceScores, IterableStream minedOpinions, int offset, int length) { @@ -61,7 +61,7 @@ public SentenceSentiment(String text, TextSentiment sentiment, SentimentConfiden /** * Get the sentence text property. * - * @return the text property value. + * @return The text property value. */ public String getText() { return this.text; @@ -97,18 +97,18 @@ public IterableStream getMinedOpinions() { } /** - * Get the offset of sentence sentiment match text. + * Get the offset of sentence. The start position for the sentence in a document. * - * @return The offset of sentence sentiment match text. + * @return The offset of sentence. */ public int getOffset() { return offset; } /** - * Get the length of sentence sentiment match text. + * Get the length of sentence. * - * @return The length of sentence sentiment match text. + * @return The length of sentence. */ public int getLength() { return length;