Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions sdk/textanalytics/azure-ai-textanalytics/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
# Release History

## 1.0.0-beta.5 (Unreleased)
**New features**
- Added Text property and `getText()` to `SentenceSentiment`.
- `Warnings` property added to each document-level response object returned from the endpoints. It is a list of `TextAnalyticsWarnings`.

**Breaking changes**
- Rename `apiKey()` to `credential()` on TextAnalyticsClientBuilder.
- Removed `getGraphemeLength()` and `getGraphemeOffset()` from `CategorizedEntity`, `SentenceSentiment`, and `LinkedEntityMatch`.
- `getGraphemeCount()` in `TextDocumentStatistics` has been renamed to `getCharacterCount()`.
- `getScore()` in `DetectedLanguage` has been renamed to `getConfidenceScore()`.
- `getSubCategory()` in `CategorizedEntity` has been renamed to `getSubcategory()`.
- `getLinkedEntityMatches()` in `LinkedEntity` has been renamed to `getMatches()`.
- `getCode()` in `TextAnalyticsException` and `TextAnalyticsError` has been renamed to `getErrorCode()`.
- `getCode()` in `TextAnalyticsWarning` has been renamed to `getWarningCode()`.
- Async client returns errors, mono error or flux error but no longer throws exception. Sync client throws exceptions only.
- Deprecated `TextDocumentInput(String id, String text, String language)` constructor, but added `setLanguage()` setter since `language` is optional.

## 1.0.0-beta.4 (2020-04-07)
- Throws an illegal argument exception when the given list of documents is an empty list.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class AnalyzeSentimentAsyncClient {
private final TextAnalyticsClientImpl service;

/**
* Create a {@link AnalyzeSentimentAsyncClient} that sends requests to the Text Analytics services's sentiment
* Create an {@link AnalyzeSentimentAsyncClient} that sends requests to the Text Analytics services's sentiment
* analysis endpoint.
*
* @param service The proxy service used to perform REST calls.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class ExtractKeyPhraseAsyncClient {
private final TextAnalyticsClientImpl service;

/**
* Create a {@link ExtractKeyPhraseAsyncClient} that sends requests to the Text Analytics services's extract
* Create an {@link ExtractKeyPhraseAsyncClient} that sends requests to the Text Analytics services's extract
* keyphrase endpoint.
*
* @param service The proxy service used to perform REST calls.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ private Utility() {
* Verify that list of documents are not null or empty. Otherwise, throw exception.
*
* @param documents A list of documents.
*
* @throws NullPointerException if {@code documents} is {@code null}.
* @throws IllegalArgumentException if {@code documents} is empty.
*/
public static void inputDocumentsValidation(Iterable<?> documents) {
Objects.requireNonNull(documents, "'documents' cannot be null.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
@Immutable
public final class DetectedLanguage {
/**
*
* Long name of a detected language (e.g. English, French).
*/
private final String name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ public final class DocumentSentiment {
/**
* Creates a {@link DocumentSentiment} model that describes the sentiment of the document.
*
* @param sentiment the sentiment label of the document.
* @param confidenceScores the sentiment confidence score (Softmax score) between 0 and 1, for each sentiment label.
* @param sentiment The sentiment label of the document.
* @param confidenceScores The sentiment confidence score (Softmax score) between 0 and 1, for each sentiment label.
* Higher values signify higher confidence.
* @param sentences a {@link IterableStream} of sentence sentiments.
* @param warnings a {@link IterableStream} of {@link TextAnalyticsWarning}.
* @param sentences An {@link IterableStream} of sentence sentiments.
* @param warnings An {@link IterableStream} of {@link TextAnalyticsWarning}.
*/
public DocumentSentiment(TextSentiment sentiment, SentimentConfidenceScores confidenceScores,
IterableStream<SentenceSentiment> sentences, IterableStream<TextAnalyticsWarning> warnings) {
Expand All @@ -37,7 +37,7 @@ public DocumentSentiment(TextSentiment sentiment, SentimentConfidenceScores conf
/**
* Get the text sentiment label: POSITIVE, NEGATIVE, NEUTRAL, or MIXED.
*
* @return the {@link TextSentiment}.
* @return The {@link TextSentiment}.
*/
public TextSentiment getSentiment() {
return sentiment;
Expand All @@ -47,7 +47,7 @@ public TextSentiment getSentiment() {
* Get the sentiment confidence score (Softmax score) between 0 and 1, for each sentiment label.
* Higher values signify higher confidence.
*
* @return the {@link SentimentConfidenceScores}.
* @return The {@link SentimentConfidenceScores}.
*/
public SentimentConfidenceScores getConfidenceScores() {
return confidenceScores;
Expand All @@ -56,7 +56,7 @@ public SentimentConfidenceScores getConfidenceScores() {
/**
* Get a list of sentence sentiments.
*
* @return a list of sentence sentiments.
* @return A list of sentence sentiments.
*/
public IterableStream<SentenceSentiment> getSentences() {
return sentences;
Expand All @@ -65,7 +65,7 @@ public IterableStream<SentenceSentiment> getSentences() {
/**
* Get the {@link IterableStream} of {@link TextAnalyticsWarning Text Analytics warnings}.
*
* @return {@link IterableStream} of {@link TextAnalyticsWarning}.
* @return An {@link IterableStream} of {@link TextAnalyticsWarning}.
*/
public IterableStream<TextAnalyticsWarning> getWarnings() {
return this.warnings;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public SentenceSentiment(String text, TextSentiment sentiment, SentimentConfiden
}

/**
* Get the sentence text property: The sentence text.
* Get the sentence text property.
*
* @return the text value.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,12 @@ public String getLanguage() {
* for Spanish etc. If not set, use "en" for English as default.
*
* @param language Optional. This is the 2 letter ISO 639-1 representation of a language.
*
* @return The object {@link TextDocumentInput} itself.
*/
public void setLanguage(String language) {
public TextDocumentInput setLanguage(String language) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm not sure i understand the context on just making setLanguage a setter and not adding it to a separate constructor like you used to have it. Is there a reason why you can't add this constructor back like it is in master:

I really don't think it's a good idea to force users to call TextDocumentInput.setLanguage("en") for the most basic version of TextDocumentInput (you're doing this in your tests). What I think you should do is have two constructors exactly how it is in master. Is there a reason why you're changing this code?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the only time constructor needed is when the parameter is required. But since language is optional. it should not go to constructor. Let's say maybe in the future, more parameter will be added to this class, we will not add another constructor if the value is not required.

this.language = language;
return this;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,8 @@ public void recognizeEntitiesStringListWithOptions() {
public void recognizeBatchEntitiesMaxOverload() {
// BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeCategorizedEntitiesBatch#Iterable-TextAnalyticsRequestOptions
List<TextDocumentInput> textDocumentInputs1 = Arrays.asList(
new TextDocumentInput("0", "I had a wonderful trip to Seattle last week."),
new TextDocumentInput("1", "I work at Microsoft."));
new TextDocumentInput("0", "I had a wonderful trip to Seattle last week.").setLanguage("en"),
new TextDocumentInput("1", "I work at Microsoft.").setLanguage("en"));

// Request options: show statistics and model version
TextAnalyticsRequestOptions requestOptions = new TextAnalyticsRequestOptions().setIncludeStatistics(true);
Expand Down Expand Up @@ -466,8 +466,8 @@ public void recognizeLinkedEntitiesStringListWithOptions() {
public void recognizeBatchLinkedEntitiesMaxOverload() {
// BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.recognizeLinkedEntitiesBatch#Iterable-TextAnalyticsRequestOptions
List<TextDocumentInput> textDocumentInputs1 = Arrays.asList(
new TextDocumentInput("0", "Old Faithful is a geyser at Yellowstone Park."),
new TextDocumentInput("1", "Mount Shasta has lenticular clouds."));
new TextDocumentInput("0", "Old Faithful is a geyser at Yellowstone Park.").setLanguage("en"),
new TextDocumentInput("1", "Mount Shasta has lenticular clouds.").setLanguage("en"));

// Request options: show statistics and model version
TextAnalyticsRequestOptions requestOptions = new TextAnalyticsRequestOptions().setIncludeStatistics(true);
Expand Down Expand Up @@ -595,8 +595,8 @@ public void extractKeyPhrasesStringListWithOptions() {
public void extractBatchKeyPhrasesMaxOverload() {
// BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.extractKeyPhrasesBatch#Iterable-TextAnalyticsRequestOptions
List<TextDocumentInput> textDocumentInputs1 = Arrays.asList(
new TextDocumentInput("0", "I had a wonderful trip to Seattle last week."),
new TextDocumentInput("1", "I work at Microsoft."));
new TextDocumentInput("0", "I had a wonderful trip to Seattle last week.").setLanguage("en"),
new TextDocumentInput("1", "I work at Microsoft.").setLanguage("en"));

// Request options: show statistics and model version
TextAnalyticsRequestOptions requestOptions = new TextAnalyticsRequestOptions().setIncludeStatistics(true);
Expand Down Expand Up @@ -766,8 +766,8 @@ public void analyzeSentimentStringListWithOptions() {
public void analyzeBatchSentimentMaxOverload() {
// BEGIN: com.azure.ai.textanalytics.TextAnalyticsAsyncClient.analyzeSentimentBatch#Iterable-TextAnalyticsRequestOptions
List<TextDocumentInput> textDocumentInputs1 = Arrays.asList(
new TextDocumentInput("0", "The hotel was dark and unclean."),
new TextDocumentInput("1", "The restaurant had amazing gnocchi."));
new TextDocumentInput("0", "The hotel was dark and unclean.").setLanguage("en"),
new TextDocumentInput("1", "The restaurant had amazing gnocchi.").setLanguage("en"));

// Request options: show statistics and model version
TextAnalyticsRequestOptions requestOptions = new TextAnalyticsRequestOptions().setIncludeStatistics(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,8 @@ public void recognizeEntitiesStringListWithOptions() {
public void recognizeBatchEntitiesMaxOverload() {
// BEGIN: com.azure.ai.textanalytics.TextAnalyticsClient.recognizeEntitiesBatch#Iterable-TextAnalyticsRequestOptions-Context
List<TextDocumentInput> textDocumentInputs = Arrays.asList(
new TextDocumentInput("0", "I had a wonderful trip to Seattle last week."),
new TextDocumentInput("1", "I work at Microsoft.")
new TextDocumentInput("0", "I had a wonderful trip to Seattle last week.").setLanguage("en"),
new TextDocumentInput("1", "I work at Microsoft.").setLanguage("en")
);

textAnalyticsClient.recognizeEntitiesBatch(textDocumentInputs,
Expand Down Expand Up @@ -464,8 +464,8 @@ public void recognizeLinkedEntitiesStringListWithOptions() {
public void recognizeLinkedEntitiesBatchMaxOverload() {
// BEGIN: com.azure.ai.textanalytics.TextAnalyticsClient.recognizeLinkedEntitiesBatch#Iterable-TextAnalyticsRequestOptions-Context
List<TextDocumentInput> textDocumentInputs = Arrays.asList(
new TextDocumentInput("1", "Old Faithful is a geyser at Yellowstone Park."),
new TextDocumentInput("2", "Mount Shasta has lenticular clouds.")
new TextDocumentInput("1", "Old Faithful is a geyser at Yellowstone Park.").setLanguage("en"),
new TextDocumentInput("2", "Mount Shasta has lenticular clouds.").setLanguage("en")
);

textAnalyticsClient.recognizeLinkedEntitiesBatch(textDocumentInputs,
Expand Down Expand Up @@ -611,8 +611,8 @@ public void extractKeyPhrasesStringListWithOptions() {
public void extractBatchKeyPhrasesMaxOverload() {
// BEGIN: com.azure.ai.textanalytics.TextAnalyticsClient.extractKeyPhrasesBatch#Iterable-TextAnalyticsRequestOptions-Context
List<TextDocumentInput> textDocumentInputs = Arrays.asList(
new TextDocumentInput("1", "My cat might need to see a veterinarian."),
new TextDocumentInput("2", "The pitot tube is used to measure airspeed.")
new TextDocumentInput("1", "My cat might need to see a veterinarian.").setLanguage("en"),
new TextDocumentInput("2", "The pitot tube is used to measure airspeed.").setLanguage("en")
);

// Extracting batch key phrases
Expand Down Expand Up @@ -822,8 +822,8 @@ public void analyzeSentimentStringListWithOptions() {
public void analyzeBatchSentimentMaxOverload() {
// BEGIN: com.azure.ai.textanalytics.TextAnalyticsClient.analyzeSentimentBatch#Iterable-TextAnalyticsRequestOptions-Context
List<TextDocumentInput> textDocumentInputs = Arrays.asList(
new TextDocumentInput("1", "The hotel was dark and unclean. The restaurant had amazing gnocchi."),
new TextDocumentInput("2", "The restaurant had amazing gnocchi. The hotel was dark and unclean.")
new TextDocumentInput("1", "The hotel was dark and unclean. The restaurant had amazing gnocchi.").setLanguage("en"),
new TextDocumentInput("2", "The restaurant had amazing gnocchi. The hotel was dark and unclean.").setLanguage("en")
);

// Analyzing batch sentiments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ public static void main(String[] args) {

// The texts that need be analyzed.
List<TextDocumentInput> documents = Arrays.asList(
new TextDocumentInput("A", "The hotel was dark and unclean. I wouldn't recommend staying there."),
new TextDocumentInput("B", "The restaurant had amazing gnocchi! The waiters were excellent."),
new TextDocumentInput("C", "The hotel was dark and unclean. The restaurant had amazing gnocchi!")
new TextDocumentInput("A", "The hotel was dark and unclean. I wouldn't recommend staying there.").setLanguage("en"),
new TextDocumentInput("B", "The restaurant had amazing gnocchi! The waiters were excellent.").setLanguage("en"),
new TextDocumentInput("C", "The hotel was dark and unclean. The restaurant had amazing gnocchi!").setLanguage("en")
);

// Request options: show statistics and model version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ public static void main(String[] args) {

// The texts that need be analyzed.
List<TextDocumentInput> documents = Arrays.asList(
new TextDocumentInput("A", "The hotel was dark and unclean. I wouldn't recommend staying there."),
new TextDocumentInput("B", "The restaurant had amazing gnocchi! The waiters were excellent."),
new TextDocumentInput("C", "The hotel was dark and unclean. The restaurant had amazing gnocchi!")
new TextDocumentInput("A", "The hotel was dark and unclean. I wouldn't recommend staying there.").setLanguage("en"),
new TextDocumentInput("B", "The restaurant had amazing gnocchi! The waiters were excellent.").setLanguage("en"),
new TextDocumentInput("C", "The hotel was dark and unclean. The restaurant had amazing gnocchi!").setLanguage("en")
);

// Request options: show statistics and model version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public static void main(String[] args) {

// The texts that need be analyzed.
List<TextDocumentInput> documents = Arrays.asList(
new TextDocumentInput("A", "The food was delicious and there were wonderful staff."),
new TextDocumentInput("B", "The pitot tube is used to measure airspeed.")
new TextDocumentInput("A", "The food was delicious and there were wonderful staff.").setLanguage("en"),
new TextDocumentInput("B", "The pitot tube is used to measure airspeed.").setLanguage("en")
);

// Request options: show statistics and model version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public static void main(String[] args) {

// The texts that need be analyzed.
List<TextDocumentInput> documents = Arrays.asList(
new TextDocumentInput("A", "My cat might need to see a veterinarian."),
new TextDocumentInput("B", "The pitot tube is used to measure airspeed.")
new TextDocumentInput("A", "My cat might need to see a veterinarian.").setLanguage("en"),
new TextDocumentInput("B", "The pitot tube is used to measure airspeed.").setLanguage("en")
);

// Request options: show statistics and model version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public static void main(String[] args) {

// The texts that need be analyzed.
List<TextDocumentInput> documents = Arrays.asList(
new TextDocumentInput("A", "Satya Nadella is the CEO of Microsoft."),
new TextDocumentInput("B", "Elon Musk is the CEO of SpaceX and Tesla.")
new TextDocumentInput("A", "Satya Nadella is the CEO of Microsoft.").setLanguage("en"),
new TextDocumentInput("B", "Elon Musk is the CEO of SpaceX and Tesla.").setLanguage("en")
);

// Request options: show statistics and model version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public static void main(String[] args) {

// The texts that need be analyzed.
List<TextDocumentInput> documents = Arrays.asList(
new TextDocumentInput("A", "Satya Nadella is the CEO of Microsoft."),
new TextDocumentInput("B", "Elon Musk is the CEO of SpaceX and Tesla.")
new TextDocumentInput("A", "Satya Nadella is the CEO of Microsoft.").setLanguage("en"),
new TextDocumentInput("B", "Elon Musk is the CEO of SpaceX and Tesla.").setLanguage("en")
);

// Request options: show statistics and model version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public static void main(String[] args) {

// The texts that need be analyzed.
List<TextDocumentInput> documents = Arrays.asList(
new TextDocumentInput("A", "Old Faithful is a geyser at Yellowstone Park."),
new TextDocumentInput("B", "Mount Shasta has lenticular clouds.")
new TextDocumentInput("A", "Old Faithful is a geyser at Yellowstone Park.").setLanguage("en"),
new TextDocumentInput("B", "Mount Shasta has lenticular clouds.").setLanguage("en")
);

// Request options: show statistics and model version
Expand All @@ -53,7 +53,7 @@ public static void main(String[] args) {
TextDocumentBatchStatistics batchStatistics = pagedResponse.getStatistics();
System.out.printf("Documents statistics: document count = %s, erroneous document count = %s, transaction count = %s, valid document count = %s.%n",
batchStatistics.getDocumentCount(), batchStatistics.getInvalidDocumentCount(), batchStatistics.getTransactionCount(), batchStatistics.getValidDocumentCount());

AtomicInteger counter = new AtomicInteger();
for (RecognizeLinkedEntitiesResult entitiesResult : pagedResponse.getElements()) {
// Recognized linked entities from documents
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public static void main(String[] args) {

// The texts that need be analyzed.
List<TextDocumentInput> documents = Arrays.asList(
new TextDocumentInput("A", "Old Faithful is a geyser at Yellowstone Park."),
new TextDocumentInput("B", "Mount Shasta has lenticular clouds.")
new TextDocumentInput("A", "Old Faithful is a geyser at Yellowstone Park.").setLanguage("en"),
new TextDocumentInput("B", "Mount Shasta has lenticular clouds.").setLanguage("en")
);

// Request options: show statistics and model version
Expand Down
Loading