Skip to content

Commit

Permalink
Merge pull request #2 from samvaity/text-analytics
Browse files Browse the repository at this point in the history
Text Analytics API review tool feedback
  • Loading branch information
samvaity authored Nov 25, 2019
2 parents 001682e + f6d4501 commit 72a00c0
Show file tree
Hide file tree
Showing 14 changed files with 103 additions and 86 deletions.
1 change: 1 addition & 0 deletions pom.client.xml
Original file line number Diff line number Diff line change
Expand Up @@ -989,5 +989,6 @@
<module>sdk/storage/azure-storage-file-datalake</module>
<module>sdk/storage/azure-storage-queue</module>
<module>sdk/storage/azure-storage-queue-cryptography</module>
<module>sdk/cognitiveservices/azure-cs-textanalytics</module>
</modules>
</project>
12 changes: 2 additions & 10 deletions sdk/cognitiveservices/azure-cs-textanalytics/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
<parent>
<groupId>com.azure</groupId>
<artifactId>azure-client-sdk-parent</artifactId>
<version>1.4.0</version>
<version>1.6.0</version>
<relativePath>../../../pom.client.xml</relativePath>
</parent>

<groupId>com.azure</groupId>
<artifactId>azure-cognitiveservices-textanalytics</artifactId>
<version>1.1.0-beta.1</version>
<version>1.0.0-beta.1</version>

<name>Microsoft Azure client library for Cognitive Services Text Analytics</name>
<description>This package contains the Microsoft Azure Cognitive Services Text Analytics SDK.</description>
Expand All @@ -38,19 +38,11 @@
<artifactId>azure-core</artifactId>
<version>1.1.0-beta.1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-core-http-netty</artifactId>
<version>1.1.0-beta.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import com.azure.cs.textanalytics.models.DocumentResultCollection;
import com.azure.cs.textanalytics.models.KeyPhraseResult;
import com.azure.cs.textanalytics.models.LinkedEntityResult;
import com.azure.cs.textanalytics.models.DetectLangaugeInput;
import com.azure.cs.textanalytics.models.DetectLanguageInput;
import com.azure.cs.textanalytics.models.NamedEntityResult;
import com.azure.cs.textanalytics.models.TextDocumentInput;
import com.azure.cs.textanalytics.models.TextAnalyticsRequestOptions;
Expand Down Expand Up @@ -83,13 +83,13 @@ public Mono<DocumentResultCollection<DetectedLanguageResult>> detectLanguages(Li

// Advantage user
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<DocumentResultCollection<DetectedLanguageResult>> detectLanguages(List<DetectLangaugeInput> inputs) {
public Mono<DocumentResultCollection<DetectedLanguageResult>> detectLanguages(List<DetectLanguageInput> inputs) {
return null;
}

@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<DocumentResultCollection<DetectedLanguageResult>> detectLanguages(
List<DetectLangaugeInput> inputs, TextAnalyticsRequestOptions options) {
List<DetectLanguageInput> inputs, TextAnalyticsRequestOptions options) {
// try {
// return withContext(
// context -> detectLanguagesWithResponse(inputs, options, context));
Expand All @@ -101,14 +101,14 @@ public Mono<DocumentResultCollection<DetectedLanguageResult>> detectLanguages(

@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<DocumentResultCollection<DetectedLanguageResult>>> detectLanguagesWithResponse(
List<DetectLangaugeInput> inputs, TextAnalyticsRequestOptions options) {
List<DetectLanguageInput> inputs, TextAnalyticsRequestOptions options) {
return null;
}

Mono<Response<DocumentResultCollection<DetectedLanguageResult>>> detectLanguagesWithResponse(
List<DetectLangaugeInput> inputs, TextAnalyticsRequestOptions options, Context context) {
List<DetectLanguageInput> inputs, TextAnalyticsRequestOptions options, Context context) {
return client.languagesWithRestResponseAsync(new LanguageBatchInput().setDocuments(inputs),
options.getModelVersion(), options.isShowStatistics(), context)
options.getModelVersion(), options.showStatistics(), context)
.map(response -> new SimpleResponse<>(response, null));
}

Expand Down Expand Up @@ -168,7 +168,7 @@ Mono<Response<DocumentResultCollection<NamedEntityResult>>> recognizeEntitiesWit
List<TextDocumentInput> document, TextAnalyticsRequestOptions options, Context context) {
return client.entitiesRecognitionGeneralWithRestResponseAsync(
new MultiLanguageBatchInput().setDocuments(document), options.getModelVersion(),
options.isShowStatistics(), context).map(response -> new SimpleResponse<>(response, null));
options.showStatistics(), context).map(response -> new SimpleResponse<>(response, null));
}

// (3) PII entities
Expand Down Expand Up @@ -228,7 +228,7 @@ Mono<Response<DocumentResultCollection<NamedEntityResult>>> recognizePiiEntities
List<TextDocumentInput> document, TextAnalyticsRequestOptions options, Context context) {
// TODO: validate multiLanguageBatchInput
return client.entitiesRecognitionPiiWithRestResponseAsync(new MultiLanguageBatchInput().setDocuments(document),
options.getModelVersion(), options.isShowStatistics(), context)
options.getModelVersion(), options.showStatistics(), context)
.map(response -> new SimpleResponse<>(response, null));
}

Expand Down Expand Up @@ -289,7 +289,7 @@ Mono<Response<DocumentResultCollection<LinkedEntityResult>>> recognizeLinkedEnti
List<TextDocumentInput> inputs, TextAnalyticsRequestOptions options, Context context) {
// TODO: validate multiLanguageBatchInput
return client.entitiesLinkingWithRestResponseAsync(new MultiLanguageBatchInput().setDocuments(inputs),
options.getModelVersion(), options.isShowStatistics(), context)
options.getModelVersion(), options.showStatistics(), context)
.map(response -> new SimpleResponse<>(response, null));
}

Expand Down Expand Up @@ -363,7 +363,7 @@ public Mono<Response<DocumentResultCollection<KeyPhraseResult>>> extractKeyPhras
Mono<Response<DocumentResultCollection<KeyPhraseResult>>> extractKeyPhrasesWithResponse(
List<TextDocumentInput> document, TextAnalyticsRequestOptions options, Context context) {
return client.keyPhrasesWithRestResponseAsync(new MultiLanguageBatchInput().setDocuments(document),
options.getModelVersion(), options.isShowStatistics(), context).map(response ->
options.getModelVersion(), options.showStatistics(), context).map(response ->
new SimpleResponse<>(response, null));
}

Expand Down Expand Up @@ -440,7 +440,7 @@ Mono<Response<DocumentResultCollection<TextSentimentResult>>> analyzeDocumentSen
List<TextDocumentInput> document, TextAnalyticsRequestOptions options, Context context) {
// TODO: validate multiLanguageBatchInput
return client.sentimentWithRestResponseAsync(
new MultiLanguageBatchInput().setDocuments(document), options.getModelVersion(), options.isShowStatistics(),
new MultiLanguageBatchInput().setDocuments(document), options.getModelVersion(), options.showStatistics(),
context).map(response -> new SimpleResponse<>(response, null));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,17 @@
import com.azure.core.annotation.ReturnType;
import com.azure.core.annotation.ServiceClient;
import com.azure.core.annotation.ServiceMethod;
import com.azure.core.http.rest.PagedIterable;
import com.azure.core.http.rest.Response;
import com.azure.core.util.Context;
import com.azure.cs.textanalytics.models.DetectedLanguage;
import com.azure.cs.textanalytics.models.DetectLanguageInput;
import com.azure.cs.textanalytics.models.DetectedLanguageResult;
import com.azure.cs.textanalytics.models.DocumentResultCollection;
import com.azure.cs.textanalytics.models.KeyPhraseResult;
import com.azure.cs.textanalytics.models.LinkedEntityResult;
import com.azure.cs.textanalytics.models.NamedEntity;
import com.azure.cs.textanalytics.models.NamedEntityResult;
import com.azure.cs.textanalytics.models.TextSentiment;
import com.azure.cs.textanalytics.models.DetectLangaugeInput;
import com.azure.cs.textanalytics.models.LinkedEntity;
import com.azure.cs.textanalytics.models.TextDocumentInput;
import com.azure.cs.textanalytics.models.TextAnalyticsRequestOptions;
import com.azure.cs.textanalytics.models.TextDocumentInput;
import com.azure.cs.textanalytics.models.TextSentimentResult;
import reactor.core.publisher.Mono;

import java.util.List;

Expand All @@ -37,7 +31,7 @@ public final class TextAnalyticsClient {
// (1) language
// new user
@ServiceMethod(returns = ReturnType.SINGLE)
public DetectedLanguageResult detectLanguage(String text) { return null;}
public DetectedLanguageResult detectLanguage(String text) { return null; }

@ServiceMethod(returns = ReturnType.SINGLE)
public DetectedLanguageResult detectLanguage(String text, String countryHint) {
Expand All @@ -58,19 +52,19 @@ public DocumentResultCollection<DetectedLanguageResult> detectLanguages(List<Str

// advantage user
@ServiceMethod(returns = ReturnType.SINGLE)
public DocumentResultCollection<DetectedLanguageResult> detectLanguages(List<DetectLangaugeInput> inputs) {
public DocumentResultCollection<DetectedLanguageResult> detectLanguages(List<DetectLanguageInput> inputs) {
return null;
}

@ServiceMethod(returns = ReturnType.SINGLE)
public DocumentResultCollection<DetectedLanguageResult> detectLanguages(
List<DetectLangaugeInput> inputs, TextAnalyticsRequestOptions options) {
List<DetectLanguageInput> inputs, TextAnalyticsRequestOptions options) {
return null;
}

@ServiceMethod(returns = ReturnType.SINGLE)
public Response<DocumentResultCollection<DetectedLanguageResult>> detectLanguagesWithResponse(
List<DetectLangaugeInput> inputs, TextAnalyticsRequestOptions options, Context context) {
List<DetectLanguageInput> inputs, TextAnalyticsRequestOptions options, Context context) {
return client.detectLanguagesWithResponse(inputs, options, context).block();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* The versions of Azure Text Analytics supported by this client library.
*/
public enum TextAnalyticsServiceVersion implements ServiceVersion {
V1_0("1.0");
V3_0_preview_1 ("v3.0-preview.1");

private final String version;

Expand All @@ -31,7 +31,7 @@ public String getVersion() {
* @return the latest {@link TextAnalyticsServiceVersion}
*/
public static TextAnalyticsServiceVersion getLatest() {
return V1_0;
return V3_0_preview_1;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import com.azure.core.annotation.ReturnType;
import com.azure.core.annotation.ServiceInterface;
import com.azure.core.annotation.ServiceMethod;
import com.azure.core.annotation.UnexpectedResponseExceptionType;
import com.azure.core.exception.HttpResponseException;
import com.azure.core.http.HttpPipeline;
import com.azure.core.http.rest.RestProxy;
import com.azure.core.http.rest.SimpleResponse;
Expand Down Expand Up @@ -95,27 +97,55 @@ public TextAnalyticsAPIImpl(HttpPipeline httpPipeline) {
private interface TextAnalyticsAPIService {
@Post("entities/recognition/general")
@ExpectedResponses({200, 500})
Mono<SimpleResponse<Object>> entitiesRecognitionGeneral(@HostParam("Endpoint") String endpoint, @QueryParam("model-version") String modelVersion, @QueryParam("showStats") Boolean showStats, @BodyParam("application/json; charset=utf-8") MultiLanguageBatchInput multiLanguageBatchInput, Context context);
@UnexpectedResponseExceptionType(HttpResponseException.class)
Mono<SimpleResponse<Object>> entitiesRecognitionGeneral(@HostParam("Endpoint") String endpoint,
@QueryParam("model-version") String modelVersion,
@QueryParam("showStats") Boolean showStats,
@BodyParam("application/json; charset=utf-8") MultiLanguageBatchInput multiLanguageBatchInput,
Context context);

@Post("entities/recognition/pii")
@ExpectedResponses({200, 500})
Mono<SimpleResponse<Object>> entitiesRecognitionPii(@HostParam("Endpoint") String endpoint, @QueryParam("model-version") String modelVersion, @QueryParam("showStats") Boolean showStats, @BodyParam("application/json; charset=utf-8") MultiLanguageBatchInput multiLanguageBatchInput, Context context);
@UnexpectedResponseExceptionType(HttpResponseException.class)
Mono<SimpleResponse<Object>> entitiesRecognitionPii(@HostParam("Endpoint") String endpoint,
@QueryParam("model-version") String modelVersion,
@QueryParam("showStats") Boolean showStats,
@BodyParam("application/json; charset=utf-8") MultiLanguageBatchInput multiLanguageBatchInput,
Context context);

@Post("entities/linking")
@ExpectedResponses({200, 500})
Mono<SimpleResponse<Object>> entitiesLinking(@HostParam("Endpoint") String endpoint, @QueryParam("model-version") String modelVersion, @QueryParam("showStats") Boolean showStats, @BodyParam("application/json; charset=utf-8") MultiLanguageBatchInput multiLanguageBatchInput, Context context);
@UnexpectedResponseExceptionType(HttpResponseException.class)
Mono<SimpleResponse<Object>> entitiesLinking(@HostParam("Endpoint") String endpoint,
@QueryParam("model-version") String modelVersion,
@QueryParam("showStats") Boolean showStats,
@BodyParam("application/json; charset=utf-8") MultiLanguageBatchInput multiLanguageBatchInput,
Context context);

@Post("keyPhrases")
@ExpectedResponses({200, 500})
Mono<SimpleResponse<Object>> keyPhrases(@HostParam("Endpoint") String endpoint, @QueryParam("model-version") String modelVersion, @QueryParam("showStats") Boolean showStats, @BodyParam("application/json; charset=utf-8") MultiLanguageBatchInput multiLanguageBatchInput, Context context);
@UnexpectedResponseExceptionType(HttpResponseException.class)
Mono<SimpleResponse<Object>> keyPhrases(@HostParam("Endpoint") String endpoint,
@QueryParam("model-version") String modelVersion,
@QueryParam("showStats") Boolean showStats,
@BodyParam("application/json; charset=utf-8") MultiLanguageBatchInput multiLanguageBatchInput,
Context context);

@Post("languages")
@ExpectedResponses({200, 500})
Mono<SimpleResponse<Object>> languages(@HostParam("Endpoint") String endpoint, @QueryParam("model-version") String modelVersion, @QueryParam("showStats") Boolean showStats, @BodyParam("application/json; charset=utf-8") LanguageBatchInput languageBatchInput, Context context);
Mono<SimpleResponse<Object>> languages(@HostParam("Endpoint") String endpoint,
@QueryParam("model-version") String modelVersion,
@QueryParam("showStats") Boolean showStats,
@BodyParam("application/json; charset=utf-8") LanguageBatchInput languageBatchInput,
Context context);

@Post("sentiment")
@ExpectedResponses({200, 500})
Mono<SimpleResponse<Object>> sentiment(@HostParam("Endpoint") String endpoint, @QueryParam("model-version") String modelVersion, @QueryParam("showStats") Boolean showStats, @BodyParam("application/json; charset=utf-8") MultiLanguageBatchInput multiLanguageBatchInput, Context context);
Mono<SimpleResponse<Object>> sentiment(@HostParam("Endpoint") String endpoint,
@QueryParam("model-version") String modelVersion,
@QueryParam("showStats") Boolean showStats,
@BodyParam("application/json; charset=utf-8") MultiLanguageBatchInput multiLanguageBatchInput,
Context context);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
package com.azure.cs.textanalytics.implementation.models;

import com.azure.core.annotation.Fluent;
import com.azure.cs.textanalytics.models.DetectLangaugeInput;
import com.azure.cs.textanalytics.models.DetectLanguageInput;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;

Expand All @@ -18,14 +18,14 @@ public final class LanguageBatchInput {
* The documents property.
*/
@JsonProperty(value = "documents", required = true)
private List<DetectLangaugeInput> documents;
private List<DetectLanguageInput> documents;

/**
* Get the documents property: The documents property.
*
* @return the documents value.
*/
public List<DetectLangaugeInput> getDocuments() {
public List<DetectLanguageInput> getDocuments() {
return this.documents;
}

Expand All @@ -35,7 +35,7 @@ public List<DetectLangaugeInput> getDocuments() {
* @param documents the documents value to set.
* @return the LanguageBatchInput object itself.
*/
public LanguageBatchInput setDocuments(List<DetectLangaugeInput> documents) {
public LanguageBatchInput setDocuments(List<DetectLanguageInput> documents) {
this.documents = documents;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
* The UnknownLanguageInput model.
*/
@Fluent
public final class DetectLangaugeInput {
public final class DetectLanguageInput {

public DetectLangaugeInput(String id, String text) {
public DetectLanguageInput(String id, String text) {
this.id = id;
this.text = text;
}
Expand Down Expand Up @@ -51,7 +51,7 @@ public String getId() {
* @param id the id value to set.
* @return the UnknownLanguageInput object itself.
*/
DetectLangaugeInput setId(String id) {
DetectLanguageInput setId(String id) {
this.id = id;
return this;
}
Expand All @@ -71,7 +71,7 @@ public String getText() {
* @param text the text value to set.
* @return the UnknownLanguageInput object itself.
*/
public DetectLangaugeInput setText(String text) {
public DetectLanguageInput setText(String text) {
this.text = text;
return this;
}
Expand All @@ -91,7 +91,7 @@ public String getCountryHint() {
* @param countryHint the countryHint value to set.
* @return the UnknownLanguageInput object itself.
*/
public DetectLangaugeInput setCountryHint(String countryHint) {
public DetectLanguageInput setCountryHint(String countryHint) {
this.countryHint = countryHint;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@Fluent
public final class DetectedLanguageResult extends DocumentResult {
private DetectedLanguage primaryLanguage;
private IterableStream<DetectedLanguage> items;
private IterableStream<DetectedLanguage> detectedLanguages;

public DetectedLanguage getPrimaryLanguage() {
return primaryLanguage;
Expand All @@ -23,12 +23,12 @@ DetectedLanguageResult setPrimaryLanguage(DetectedLanguage detectedLanguage) {
return this;
}

public IterableStream<DetectedLanguage> getItems() {
return items;
public IterableStream<DetectedLanguage> getDetectedLanguages() {
return detectedLanguages;
}

DetectedLanguageResult setItems(IterableStream<DetectedLanguage> items) {
this.items = items;
DetectedLanguageResult setDetectedLanguages(IterableStream<DetectedLanguage> detectedLanguages) {
this.detectedLanguages = detectedLanguages;
return this;
}
}
Loading

0 comments on commit 72a00c0

Please sign in to comment.