From 5434b0a6ed388eb373953f07a7159e034de2e083 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Tue, 1 May 2018 00:43:47 +0000 Subject: [PATCH] Generated from 0e4a71a5607b0d0e1a69c094161ed968ce7dbc25 Update SDK folder in CSharp configs --- .../textanalytics/AzureRegions.java | 83 ++ .../textanalytics/BatchInput.java | 45 + .../textanalytics/DetectedLanguage.java | 97 +++ .../EntitiesBatchResultItem.java | 48 + .../textanalytics/EntityRecord.java | 153 ++++ .../textanalytics/ErrorRecord.java | 69 ++ .../textanalytics/ErrorResponse.java | 121 +++ .../textanalytics/ErrorResponseException.java | 44 + .../textanalytics/InternalError.java | 95 ++ .../KeyPhraseBatchResultItem.java | 49 ++ .../LanguageBatchResultItem.java | 48 + .../textanalytics/MatchRecord.java | 95 ++ .../MultiLanguageBatchInput.java | 45 + .../SentimentBatchResultItem.java | 50 ++ .../EntitiesBatchResultInner.java | 50 ++ .../implementation/InputInner.java | 69 ++ .../KeyPhraseBatchResultInner.java | 50 ++ .../LanguageBatchResultInner.java | 50 ++ .../MultiLanguageInputInner.java | 96 ++ .../SentimentBatchResultInner.java | 50 ++ .../implementation/TextAnalyticsAPIImpl.java | 824 ++++++++++++++++++ .../implementation/package-info.java | 11 + .../textanalytics/package-info.java | 11 + 23 files changed, 2253 insertions(+) create mode 100644 azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/AzureRegions.java create mode 100644 azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/BatchInput.java create mode 100644 azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/DetectedLanguage.java create mode 100644 azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/EntitiesBatchResultItem.java create mode 100644 azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/EntityRecord.java create mode 100644 azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/ErrorRecord.java create mode 100644 azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/ErrorResponse.java create mode 100644 azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/ErrorResponseException.java create mode 100644 azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/InternalError.java create mode 100644 azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/KeyPhraseBatchResultItem.java create mode 100644 azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/LanguageBatchResultItem.java create mode 100644 azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/MatchRecord.java create mode 100644 azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/MultiLanguageBatchInput.java create mode 100644 azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/SentimentBatchResultItem.java create mode 100644 azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/implementation/EntitiesBatchResultInner.java create mode 100644 azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/implementation/InputInner.java create mode 100644 azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/implementation/KeyPhraseBatchResultInner.java create mode 100644 azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/implementation/LanguageBatchResultInner.java create mode 100644 azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/implementation/MultiLanguageInputInner.java create mode 100644 azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/implementation/SentimentBatchResultInner.java create mode 100644 azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/implementation/TextAnalyticsAPIImpl.java create mode 100644 azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/implementation/package-info.java create mode 100644 azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/package-info.java diff --git a/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/AzureRegions.java b/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/AzureRegions.java new file mode 100644 index 00000000000..ee978e2b05e --- /dev/null +++ b/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/AzureRegions.java @@ -0,0 +1,83 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.textanalytics; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Defines values for AzureRegions. + */ +public enum AzureRegions { + /** Enum value westus. */ + WESTUS("westus"), + + /** Enum value westeurope. */ + WESTEUROPE("westeurope"), + + /** Enum value southeastasia. */ + SOUTHEASTASIA("southeastasia"), + + /** Enum value eastus2. */ + EASTUS2("eastus2"), + + /** Enum value westcentralus. */ + WESTCENTRALUS("westcentralus"), + + /** Enum value westus2. */ + WESTUS2("westus2"), + + /** Enum value eastus. */ + EASTUS("eastus"), + + /** Enum value southcentralus. */ + SOUTHCENTRALUS("southcentralus"), + + /** Enum value northeurope. */ + NORTHEUROPE("northeurope"), + + /** Enum value eastasia. */ + EASTASIA("eastasia"), + + /** Enum value australiaeast. */ + AUSTRALIAEAST("australiaeast"), + + /** Enum value brazilsouth. */ + BRAZILSOUTH("brazilsouth"); + + /** The actual serialized value for a AzureRegions instance. */ + private String value; + + AzureRegions(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a AzureRegions instance. + * + * @param value the serialized value to parse. + * @return the parsed AzureRegions object, or null if unable to parse. + */ + @JsonCreator + public static AzureRegions fromString(String value) { + AzureRegions[] items = AzureRegions.values(); + for (AzureRegions item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/BatchInput.java b/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/BatchInput.java new file mode 100644 index 00000000000..4da4421fda2 --- /dev/null +++ b/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/BatchInput.java @@ -0,0 +1,45 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.textanalytics; + +import java.util.List; +import com.microsoft.azure.cognitiveservices.textanalytics.implementation.InputInner; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The BatchInput model. + */ +public class BatchInput { + /** + * The documents property. + */ + @JsonProperty(value = "documents") + private List documents; + + /** + * Get the documents value. + * + * @return the documents value + */ + public List documents() { + return this.documents; + } + + /** + * Set the documents value. + * + * @param documents the documents value to set + * @return the BatchInput object itself. + */ + public BatchInput withDocuments(List documents) { + this.documents = documents; + return this; + } + +} diff --git a/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/DetectedLanguage.java b/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/DetectedLanguage.java new file mode 100644 index 00000000000..9edde210b75 --- /dev/null +++ b/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/DetectedLanguage.java @@ -0,0 +1,97 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.textanalytics; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The DetectedLanguage model. + */ +public class DetectedLanguage { + /** + * Long name of a detected language (e.g. English, French). + */ + @JsonProperty(value = "name") + private String name; + + /** + * A two letter representation of the detected language according to the + * ISO 639-1 standard (e.g. en, fr). + */ + @JsonProperty(value = "iso6391Name") + private String iso6391Name; + + /** + * A confidence score between 0 and 1. Scores close to 1 indicate 100% + * certainty that the identified language is true. + */ + @JsonProperty(value = "score") + private Double score; + + /** + * Get the name value. + * + * @return the name value + */ + public String name() { + return this.name; + } + + /** + * Set the name value. + * + * @param name the name value to set + * @return the DetectedLanguage object itself. + */ + public DetectedLanguage withName(String name) { + this.name = name; + return this; + } + + /** + * Get the iso6391Name value. + * + * @return the iso6391Name value + */ + public String iso6391Name() { + return this.iso6391Name; + } + + /** + * Set the iso6391Name value. + * + * @param iso6391Name the iso6391Name value to set + * @return the DetectedLanguage object itself. + */ + public DetectedLanguage withIso6391Name(String iso6391Name) { + this.iso6391Name = iso6391Name; + return this; + } + + /** + * Get the score value. + * + * @return the score value + */ + public Double score() { + return this.score; + } + + /** + * Set the score value. + * + * @param score the score value to set + * @return the DetectedLanguage object itself. + */ + public DetectedLanguage withScore(Double score) { + this.score = score; + return this; + } + +} diff --git a/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/EntitiesBatchResultItem.java b/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/EntitiesBatchResultItem.java new file mode 100644 index 00000000000..aff8ed978e3 --- /dev/null +++ b/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/EntitiesBatchResultItem.java @@ -0,0 +1,48 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.textanalytics; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The EntitiesBatchResultItem model. + */ +public class EntitiesBatchResultItem { + /** + * Unique document identifier. + */ + @JsonProperty(value = "id", access = JsonProperty.Access.WRITE_ONLY) + private String id; + + /** + * Recognized entities in the document. + */ + @JsonProperty(value = "entities", access = JsonProperty.Access.WRITE_ONLY) + private List entities; + + /** + * Get the id value. + * + * @return the id value + */ + public String id() { + return this.id; + } + + /** + * Get the entities value. + * + * @return the entities value + */ + public List entities() { + return this.entities; + } + +} diff --git a/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/EntityRecord.java b/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/EntityRecord.java new file mode 100644 index 00000000000..2aef7837510 --- /dev/null +++ b/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/EntityRecord.java @@ -0,0 +1,153 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.textanalytics; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The EntityRecord model. + */ +public class EntityRecord { + /** + * Entity formal name. + */ + @JsonProperty(value = "name") + private String name; + + /** + * List of instances this entity appears in the text. + */ + @JsonProperty(value = "matches", access = JsonProperty.Access.WRITE_ONLY) + private List matches; + + /** + * Wikipedia language for which the WikipediaId and WikipediaUrl refers to. + */ + @JsonProperty(value = "wikipediaLanguage") + private String wikipediaLanguage; + + /** + * Wikipedia unique identifier of the recognized entity. + */ + @JsonProperty(value = "wikipediaId") + private String wikipediaId; + + /** + * URL for the entity's English Wikipedia page. + */ + @JsonProperty(value = "wikipediaUrl", access = JsonProperty.Access.WRITE_ONLY) + private String wikipediaUrl; + + /** + * Bing unique identifier of the recognized entity. Use in conjunction with + * the Bing Entity Search API to fetch additional relevant information. + */ + @JsonProperty(value = "bingId") + private String bingId; + + /** + * Get the name value. + * + * @return the name value + */ + public String name() { + return this.name; + } + + /** + * Set the name value. + * + * @param name the name value to set + * @return the EntityRecord object itself. + */ + public EntityRecord withName(String name) { + this.name = name; + return this; + } + + /** + * Get the matches value. + * + * @return the matches value + */ + public List matches() { + return this.matches; + } + + /** + * Get the wikipediaLanguage value. + * + * @return the wikipediaLanguage value + */ + public String wikipediaLanguage() { + return this.wikipediaLanguage; + } + + /** + * Set the wikipediaLanguage value. + * + * @param wikipediaLanguage the wikipediaLanguage value to set + * @return the EntityRecord object itself. + */ + public EntityRecord withWikipediaLanguage(String wikipediaLanguage) { + this.wikipediaLanguage = wikipediaLanguage; + return this; + } + + /** + * Get the wikipediaId value. + * + * @return the wikipediaId value + */ + public String wikipediaId() { + return this.wikipediaId; + } + + /** + * Set the wikipediaId value. + * + * @param wikipediaId the wikipediaId value to set + * @return the EntityRecord object itself. + */ + public EntityRecord withWikipediaId(String wikipediaId) { + this.wikipediaId = wikipediaId; + return this; + } + + /** + * Get the wikipediaUrl value. + * + * @return the wikipediaUrl value + */ + public String wikipediaUrl() { + return this.wikipediaUrl; + } + + /** + * Get the bingId value. + * + * @return the bingId value + */ + public String bingId() { + return this.bingId; + } + + /** + * Set the bingId value. + * + * @param bingId the bingId value to set + * @return the EntityRecord object itself. + */ + public EntityRecord withBingId(String bingId) { + this.bingId = bingId; + return this; + } + +} diff --git a/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/ErrorRecord.java b/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/ErrorRecord.java new file mode 100644 index 00000000000..e77e0596bab --- /dev/null +++ b/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/ErrorRecord.java @@ -0,0 +1,69 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.textanalytics; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The ErrorRecord model. + */ +public class ErrorRecord { + /** + * Input document unique identifier the error refers to. + */ + @JsonProperty(value = "id") + private String id; + + /** + * Error message. + */ + @JsonProperty(value = "message") + private String message; + + /** + * Get the id value. + * + * @return the id value + */ + public String id() { + return this.id; + } + + /** + * Set the id value. + * + * @param id the id value to set + * @return the ErrorRecord object itself. + */ + public ErrorRecord withId(String id) { + this.id = id; + return this; + } + + /** + * Get the message value. + * + * @return the message value + */ + public String message() { + return this.message; + } + + /** + * Set the message value. + * + * @param message the message value to set + * @return the ErrorRecord object itself. + */ + public ErrorRecord withMessage(String message) { + this.message = message; + return this; + } + +} diff --git a/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/ErrorResponse.java b/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/ErrorResponse.java new file mode 100644 index 00000000000..e64f89baf3e --- /dev/null +++ b/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/ErrorResponse.java @@ -0,0 +1,121 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.textanalytics; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The ErrorResponse model. + */ +public class ErrorResponse { + /** + * The code property. + */ + @JsonProperty(value = "code") + private String code; + + /** + * The message property. + */ + @JsonProperty(value = "message") + private String message; + + /** + * The target property. + */ + @JsonProperty(value = "target") + private String target; + + /** + * The innerError property. + */ + @JsonProperty(value = "innerError") + private InternalError innerError; + + /** + * Get the code value. + * + * @return the code value + */ + public String code() { + return this.code; + } + + /** + * Set the code value. + * + * @param code the code value to set + * @return the ErrorResponse object itself. + */ + public ErrorResponse withCode(String code) { + this.code = code; + return this; + } + + /** + * Get the message value. + * + * @return the message value + */ + public String message() { + return this.message; + } + + /** + * Set the message value. + * + * @param message the message value to set + * @return the ErrorResponse object itself. + */ + public ErrorResponse withMessage(String message) { + this.message = message; + return this; + } + + /** + * Get the target value. + * + * @return the target value + */ + public String target() { + return this.target; + } + + /** + * Set the target value. + * + * @param target the target value to set + * @return the ErrorResponse object itself. + */ + public ErrorResponse withTarget(String target) { + this.target = target; + return this; + } + + /** + * Get the innerError value. + * + * @return the innerError value + */ + public InternalError innerError() { + return this.innerError; + } + + /** + * Set the innerError value. + * + * @param innerError the innerError value to set + * @return the ErrorResponse object itself. + */ + public ErrorResponse withInnerError(InternalError innerError) { + this.innerError = innerError; + return this; + } + +} diff --git a/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/ErrorResponseException.java b/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/ErrorResponseException.java new file mode 100644 index 00000000000..4d6315aa4c8 --- /dev/null +++ b/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/ErrorResponseException.java @@ -0,0 +1,44 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.textanalytics; + +import com.microsoft.rest.RestException; +import okhttp3.ResponseBody; +import retrofit2.Response; + +/** + * Exception thrown for an invalid response with ErrorResponse information. + */ +public class ErrorResponseException extends RestException { + /** + * Initializes a new instance of the ErrorResponseException class. + * + * @param message the exception message or the response content if a message is not available + * @param response the HTTP response + */ + public ErrorResponseException(final String message, final Response response) { + super(message, response); + } + + /** + * Initializes a new instance of the ErrorResponseException class. + * + * @param message the exception message or the response content if a message is not available + * @param response the HTTP response + * @param body the deserialized response body + */ + public ErrorResponseException(final String message, final Response response, final ErrorResponse body) { + super(message, response, body); + } + + @Override + public ErrorResponse body() { + return (ErrorResponse) super.body(); + } +} diff --git a/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/InternalError.java b/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/InternalError.java new file mode 100644 index 00000000000..7c1840fc578 --- /dev/null +++ b/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/InternalError.java @@ -0,0 +1,95 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.textanalytics; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The InternalError model. + */ +public class InternalError { + /** + * The code property. + */ + @JsonProperty(value = "code") + private String code; + + /** + * The message property. + */ + @JsonProperty(value = "message") + private String message; + + /** + * The innerError property. + */ + @JsonProperty(value = "innerError") + private InternalError innerError; + + /** + * Get the code value. + * + * @return the code value + */ + public String code() { + return this.code; + } + + /** + * Set the code value. + * + * @param code the code value to set + * @return the InternalError object itself. + */ + public InternalError withCode(String code) { + this.code = code; + return this; + } + + /** + * Get the message value. + * + * @return the message value + */ + public String message() { + return this.message; + } + + /** + * Set the message value. + * + * @param message the message value to set + * @return the InternalError object itself. + */ + public InternalError withMessage(String message) { + this.message = message; + return this; + } + + /** + * Get the innerError value. + * + * @return the innerError value + */ + public InternalError innerError() { + return this.innerError; + } + + /** + * Set the innerError value. + * + * @param innerError the innerError value to set + * @return the InternalError object itself. + */ + public InternalError withInnerError(InternalError innerError) { + this.innerError = innerError; + return this; + } + +} diff --git a/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/KeyPhraseBatchResultItem.java b/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/KeyPhraseBatchResultItem.java new file mode 100644 index 00000000000..703c853dd59 --- /dev/null +++ b/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/KeyPhraseBatchResultItem.java @@ -0,0 +1,49 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.textanalytics; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The KeyPhraseBatchResultItem model. + */ +public class KeyPhraseBatchResultItem { + /** + * A list of representative words or phrases. The number of key phrases + * returned is proportional to the number of words in the input document. + */ + @JsonProperty(value = "keyPhrases", access = JsonProperty.Access.WRITE_ONLY) + private List keyPhrases; + + /** + * Unique document identifier. + */ + @JsonProperty(value = "id", access = JsonProperty.Access.WRITE_ONLY) + private String id; + + /** + * Get the keyPhrases value. + * + * @return the keyPhrases value + */ + public List keyPhrases() { + return this.keyPhrases; + } + + /** + * Get the id value. + * + * @return the id value + */ + public String id() { + return this.id; + } + +} diff --git a/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/LanguageBatchResultItem.java b/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/LanguageBatchResultItem.java new file mode 100644 index 00000000000..d34bbd3d7f3 --- /dev/null +++ b/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/LanguageBatchResultItem.java @@ -0,0 +1,48 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.textanalytics; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The LanguageBatchResultItem model. + */ +public class LanguageBatchResultItem { + /** + * Unique document identifier. + */ + @JsonProperty(value = "id", access = JsonProperty.Access.WRITE_ONLY) + private String id; + + /** + * A list of extracted languages. + */ + @JsonProperty(value = "detectedLanguages", access = JsonProperty.Access.WRITE_ONLY) + private List detectedLanguages; + + /** + * Get the id value. + * + * @return the id value + */ + public String id() { + return this.id; + } + + /** + * Get the detectedLanguages value. + * + * @return the detectedLanguages value + */ + public List detectedLanguages() { + return this.detectedLanguages; + } + +} diff --git a/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/MatchRecord.java b/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/MatchRecord.java new file mode 100644 index 00000000000..f11fff50d3b --- /dev/null +++ b/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/MatchRecord.java @@ -0,0 +1,95 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.textanalytics; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The MatchRecord model. + */ +public class MatchRecord { + /** + * Entity text as appears in the request. + */ + @JsonProperty(value = "text") + private String text; + + /** + * Start position (in Unicode characters) for the entity match text. + */ + @JsonProperty(value = "offset") + private Integer offset; + + /** + * Length (in Unicode characters) for the entity match text. + */ + @JsonProperty(value = "length") + private Integer length; + + /** + * Get the text value. + * + * @return the text value + */ + public String text() { + return this.text; + } + + /** + * Set the text value. + * + * @param text the text value to set + * @return the MatchRecord object itself. + */ + public MatchRecord withText(String text) { + this.text = text; + return this; + } + + /** + * Get the offset value. + * + * @return the offset value + */ + public Integer offset() { + return this.offset; + } + + /** + * Set the offset value. + * + * @param offset the offset value to set + * @return the MatchRecord object itself. + */ + public MatchRecord withOffset(Integer offset) { + this.offset = offset; + return this; + } + + /** + * Get the length value. + * + * @return the length value + */ + public Integer length() { + return this.length; + } + + /** + * Set the length value. + * + * @param length the length value to set + * @return the MatchRecord object itself. + */ + public MatchRecord withLength(Integer length) { + this.length = length; + return this; + } + +} diff --git a/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/MultiLanguageBatchInput.java b/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/MultiLanguageBatchInput.java new file mode 100644 index 00000000000..2f87272b2a4 --- /dev/null +++ b/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/MultiLanguageBatchInput.java @@ -0,0 +1,45 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.textanalytics; + +import java.util.List; +import com.microsoft.azure.cognitiveservices.textanalytics.implementation.MultiLanguageInputInner; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The MultiLanguageBatchInput model. + */ +public class MultiLanguageBatchInput { + /** + * The documents property. + */ + @JsonProperty(value = "documents") + private List documents; + + /** + * Get the documents value. + * + * @return the documents value + */ + public List documents() { + return this.documents; + } + + /** + * Set the documents value. + * + * @param documents the documents value to set + * @return the MultiLanguageBatchInput object itself. + */ + public MultiLanguageBatchInput withDocuments(List documents) { + this.documents = documents; + return this; + } + +} diff --git a/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/SentimentBatchResultItem.java b/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/SentimentBatchResultItem.java new file mode 100644 index 00000000000..57d967b87ae --- /dev/null +++ b/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/SentimentBatchResultItem.java @@ -0,0 +1,50 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.textanalytics; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The SentimentBatchResultItem model. + */ +public class SentimentBatchResultItem { + /** + * A decimal number between 0 and 1 denoting the sentiment of the document. + * A score above 0.7 usually refers to a positive document while a score + * below 0.3 normally has a negative connotation. Mid values refer to + * neutral text. + */ + @JsonProperty(value = "score", access = JsonProperty.Access.WRITE_ONLY) + private Double score; + + /** + * Unique document identifier. + */ + @JsonProperty(value = "id", access = JsonProperty.Access.WRITE_ONLY) + private String id; + + /** + * Get the score value. + * + * @return the score value + */ + public Double score() { + return this.score; + } + + /** + * Get the id value. + * + * @return the id value + */ + public String id() { + return this.id; + } + +} diff --git a/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/implementation/EntitiesBatchResultInner.java b/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/implementation/EntitiesBatchResultInner.java new file mode 100644 index 00000000000..ca21336f29d --- /dev/null +++ b/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/implementation/EntitiesBatchResultInner.java @@ -0,0 +1,50 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.textanalytics.implementation; + +import java.util.List; +import com.microsoft.azure.cognitiveservices.textanalytics.EntitiesBatchResultItem; +import com.microsoft.azure.cognitiveservices.textanalytics.ErrorRecord; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The EntitiesBatchResultInner model. + */ +public class EntitiesBatchResultInner { + /** + * The documents property. + */ + @JsonProperty(value = "documents", access = JsonProperty.Access.WRITE_ONLY) + private List documents; + + /** + * The errors property. + */ + @JsonProperty(value = "errors", access = JsonProperty.Access.WRITE_ONLY) + private List errors; + + /** + * Get the documents value. + * + * @return the documents value + */ + public List documents() { + return this.documents; + } + + /** + * Get the errors value. + * + * @return the errors value + */ + public List errors() { + return this.errors; + } + +} diff --git a/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/implementation/InputInner.java b/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/implementation/InputInner.java new file mode 100644 index 00000000000..7a8adf47c58 --- /dev/null +++ b/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/implementation/InputInner.java @@ -0,0 +1,69 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.textanalytics.implementation; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The InputInner model. + */ +public class InputInner { + /** + * Unique, non-empty document identifier. + */ + @JsonProperty(value = "id") + private String id; + + /** + * The text property. + */ + @JsonProperty(value = "text") + private String text; + + /** + * Get the id value. + * + * @return the id value + */ + public String id() { + return this.id; + } + + /** + * Set the id value. + * + * @param id the id value to set + * @return the InputInner object itself. + */ + public InputInner withId(String id) { + this.id = id; + return this; + } + + /** + * Get the text value. + * + * @return the text value + */ + public String text() { + return this.text; + } + + /** + * Set the text value. + * + * @param text the text value to set + * @return the InputInner object itself. + */ + public InputInner withText(String text) { + this.text = text; + return this; + } + +} diff --git a/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/implementation/KeyPhraseBatchResultInner.java b/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/implementation/KeyPhraseBatchResultInner.java new file mode 100644 index 00000000000..ad912f702c7 --- /dev/null +++ b/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/implementation/KeyPhraseBatchResultInner.java @@ -0,0 +1,50 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.textanalytics.implementation; + +import java.util.List; +import com.microsoft.azure.cognitiveservices.textanalytics.KeyPhraseBatchResultItem; +import com.microsoft.azure.cognitiveservices.textanalytics.ErrorRecord; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The KeyPhraseBatchResultInner model. + */ +public class KeyPhraseBatchResultInner { + /** + * The documents property. + */ + @JsonProperty(value = "documents", access = JsonProperty.Access.WRITE_ONLY) + private List documents; + + /** + * The errors property. + */ + @JsonProperty(value = "errors", access = JsonProperty.Access.WRITE_ONLY) + private List errors; + + /** + * Get the documents value. + * + * @return the documents value + */ + public List documents() { + return this.documents; + } + + /** + * Get the errors value. + * + * @return the errors value + */ + public List errors() { + return this.errors; + } + +} diff --git a/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/implementation/LanguageBatchResultInner.java b/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/implementation/LanguageBatchResultInner.java new file mode 100644 index 00000000000..17102de1063 --- /dev/null +++ b/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/implementation/LanguageBatchResultInner.java @@ -0,0 +1,50 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.textanalytics.implementation; + +import java.util.List; +import com.microsoft.azure.cognitiveservices.textanalytics.LanguageBatchResultItem; +import com.microsoft.azure.cognitiveservices.textanalytics.ErrorRecord; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The LanguageBatchResultInner model. + */ +public class LanguageBatchResultInner { + /** + * The documents property. + */ + @JsonProperty(value = "documents", access = JsonProperty.Access.WRITE_ONLY) + private List documents; + + /** + * The errors property. + */ + @JsonProperty(value = "errors", access = JsonProperty.Access.WRITE_ONLY) + private List errors; + + /** + * Get the documents value. + * + * @return the documents value + */ + public List documents() { + return this.documents; + } + + /** + * Get the errors value. + * + * @return the errors value + */ + public List errors() { + return this.errors; + } + +} diff --git a/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/implementation/MultiLanguageInputInner.java b/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/implementation/MultiLanguageInputInner.java new file mode 100644 index 00000000000..ac04a060f8c --- /dev/null +++ b/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/implementation/MultiLanguageInputInner.java @@ -0,0 +1,96 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.textanalytics.implementation; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The MultiLanguageInputInner model. + */ +public class MultiLanguageInputInner { + /** + * This is the 2 letter ISO 639-1 representation of a language. For + * example, use "en" for English; "es" for Spanish etc.,. + */ + @JsonProperty(value = "language") + private String language; + + /** + * Unique, non-empty document identifier. + */ + @JsonProperty(value = "id") + private String id; + + /** + * The text property. + */ + @JsonProperty(value = "text") + private String text; + + /** + * Get the language value. + * + * @return the language value + */ + public String language() { + return this.language; + } + + /** + * Set the language value. + * + * @param language the language value to set + * @return the MultiLanguageInputInner object itself. + */ + public MultiLanguageInputInner withLanguage(String language) { + this.language = language; + return this; + } + + /** + * Get the id value. + * + * @return the id value + */ + public String id() { + return this.id; + } + + /** + * Set the id value. + * + * @param id the id value to set + * @return the MultiLanguageInputInner object itself. + */ + public MultiLanguageInputInner withId(String id) { + this.id = id; + return this; + } + + /** + * Get the text value. + * + * @return the text value + */ + public String text() { + return this.text; + } + + /** + * Set the text value. + * + * @param text the text value to set + * @return the MultiLanguageInputInner object itself. + */ + public MultiLanguageInputInner withText(String text) { + this.text = text; + return this; + } + +} diff --git a/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/implementation/SentimentBatchResultInner.java b/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/implementation/SentimentBatchResultInner.java new file mode 100644 index 00000000000..aeed1c8336f --- /dev/null +++ b/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/implementation/SentimentBatchResultInner.java @@ -0,0 +1,50 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.textanalytics.implementation; + +import java.util.List; +import com.microsoft.azure.cognitiveservices.textanalytics.SentimentBatchResultItem; +import com.microsoft.azure.cognitiveservices.textanalytics.ErrorRecord; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The SentimentBatchResultInner model. + */ +public class SentimentBatchResultInner { + /** + * The documents property. + */ + @JsonProperty(value = "documents", access = JsonProperty.Access.WRITE_ONLY) + private List documents; + + /** + * The errors property. + */ + @JsonProperty(value = "errors", access = JsonProperty.Access.WRITE_ONLY) + private List errors; + + /** + * Get the documents value. + * + * @return the documents value + */ + public List documents() { + return this.documents; + } + + /** + * Get the errors value. + * + * @return the errors value + */ + public List errors() { + return this.errors; + } + +} diff --git a/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/implementation/TextAnalyticsAPIImpl.java b/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/implementation/TextAnalyticsAPIImpl.java new file mode 100644 index 00000000000..333e8722c94 --- /dev/null +++ b/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/implementation/TextAnalyticsAPIImpl.java @@ -0,0 +1,824 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.cognitiveservices.textanalytics.implementation; + +import com.google.common.base.Joiner; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.AzureClient; +import com.microsoft.azure.AzureServiceClient; +import com.microsoft.azure.cognitiveservices.textanalytics.AzureRegions; +import com.microsoft.azure.cognitiveservices.textanalytics.BatchInput; +import com.microsoft.azure.cognitiveservices.textanalytics.ErrorResponseException; +import com.microsoft.azure.cognitiveservices.textanalytics.MultiLanguageBatchInput; +import com.microsoft.rest.credentials.ServiceClientCredentials; +import com.microsoft.rest.RestClient; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import com.microsoft.rest.Validator; +import java.io.IOException; +import java.util.List; +import okhttp3.ResponseBody; +import retrofit2.http.Body; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.POST; +import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; + +/** + * Initializes a new instance of the TextAnalyticsAPIImpl class. + */ +public class TextAnalyticsAPIImpl extends AzureServiceClient { + /** The Retrofit service to perform REST calls. */ + private TextAnalyticsAPIService service; + /** the {@link AzureClient} used for long running operations. */ + private AzureClient azureClient; + + /** + * Gets the {@link AzureClient} used for long running operations. + * @return the azure client; + */ + public AzureClient getAzureClient() { + return this.azureClient; + } + + /** Supported Azure regions for Cognitive Services endpoints. Possible values include: 'westus', 'westeurope', 'southeastasia', 'eastus2', 'westcentralus', 'westus2', 'eastus', 'southcentralus', 'northeurope', 'eastasia', 'australiaeast', 'brazilsouth'. */ + private AzureRegions azureRegion; + + /** + * Gets Supported Azure regions for Cognitive Services endpoints. Possible values include: 'westus', 'westeurope', 'southeastasia', 'eastus2', 'westcentralus', 'westus2', 'eastus', 'southcentralus', 'northeurope', 'eastasia', 'australiaeast', 'brazilsouth'. + * + * @return the azureRegion value. + */ + public AzureRegions azureRegion() { + return this.azureRegion; + } + + /** + * Sets Supported Azure regions for Cognitive Services endpoints. Possible values include: 'westus', 'westeurope', 'southeastasia', 'eastus2', 'westcentralus', 'westus2', 'eastus', 'southcentralus', 'northeurope', 'eastasia', 'australiaeast', 'brazilsouth'. + * + * @param azureRegion the azureRegion value. + * @return the service client itself + */ + public TextAnalyticsAPIImpl withAzureRegion(AzureRegions azureRegion) { + this.azureRegion = azureRegion; + return this; + } + + /** Gets or sets the preferred language for the response. */ + private String acceptLanguage; + + /** + * Gets Gets or sets the preferred language for the response. + * + * @return the acceptLanguage value. + */ + public String acceptLanguage() { + return this.acceptLanguage; + } + + /** + * Sets Gets or sets the preferred language for the response. + * + * @param acceptLanguage the acceptLanguage value. + * @return the service client itself + */ + public TextAnalyticsAPIImpl withAcceptLanguage(String acceptLanguage) { + this.acceptLanguage = acceptLanguage; + return this; + } + + /** Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. */ + private int longRunningOperationRetryTimeout; + + /** + * Gets Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. + * + * @return the longRunningOperationRetryTimeout value. + */ + public int longRunningOperationRetryTimeout() { + return this.longRunningOperationRetryTimeout; + } + + /** + * Sets Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. + * + * @param longRunningOperationRetryTimeout the longRunningOperationRetryTimeout value. + * @return the service client itself + */ + public TextAnalyticsAPIImpl withLongRunningOperationRetryTimeout(int longRunningOperationRetryTimeout) { + this.longRunningOperationRetryTimeout = longRunningOperationRetryTimeout; + return this; + } + + /** When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. */ + private boolean generateClientRequestId; + + /** + * Gets When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. + * + * @return the generateClientRequestId value. + */ + public boolean generateClientRequestId() { + return this.generateClientRequestId; + } + + /** + * Sets When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. + * + * @param generateClientRequestId the generateClientRequestId value. + * @return the service client itself + */ + public TextAnalyticsAPIImpl withGenerateClientRequestId(boolean generateClientRequestId) { + this.generateClientRequestId = generateClientRequestId; + return this; + } + + /** + * Initializes an instance of TextAnalyticsAPI client. + * + * @param credentials the management credentials for Azure + */ + public TextAnalyticsAPIImpl(ServiceClientCredentials credentials) { + this("https://{AzureRegion}.api.cognitive.microsoft.com/text/analytics", credentials); + } + + /** + * Initializes an instance of TextAnalyticsAPI client. + * + * @param baseUrl the base URL of the host + * @param credentials the management credentials for Azure + */ + private TextAnalyticsAPIImpl(String baseUrl, ServiceClientCredentials credentials) { + super(baseUrl, credentials); + initialize(); + } + + /** + * Initializes an instance of TextAnalyticsAPI client. + * + * @param restClient the REST client to connect to Azure. + */ + public TextAnalyticsAPIImpl(RestClient restClient) { + super(restClient); + initialize(); + } + + protected void initialize() { + this.acceptLanguage = "en-US"; + this.longRunningOperationRetryTimeout = 30; + this.generateClientRequestId = true; + this.azureClient = new AzureClient(this); + initializeService(); + } + + /** + * Gets the User-Agent header for the client. + * + * @return the user agent string. + */ + @Override + public String userAgent() { + return String.format("%s (%s, %s)", super.userAgent(), "TextAnalyticsAPI", "v2.0"); + } + + private void initializeService() { + service = restClient().retrofit().create(TextAnalyticsAPIService.class); + } + + /** + * The interface defining all the services for TextAnalyticsAPI to be + * used by Retrofit to perform actually REST calls. + */ + interface TextAnalyticsAPIService { + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.textanalytics.TextAnalyticsAPI keyPhrases" }) + @POST("v2.0/keyPhrases") + Observable> keyPhrases(@Header("accept-language") String acceptLanguage, @Body MultiLanguageBatchInput input, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.textanalytics.TextAnalyticsAPI detectLanguage" }) + @POST("v2.0/languages") + Observable> detectLanguage(@Header("accept-language") String acceptLanguage, @Body BatchInput input, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.textanalytics.TextAnalyticsAPI sentiment" }) + @POST("v2.0/sentiment") + Observable> sentiment(@Header("accept-language") String acceptLanguage, @Body MultiLanguageBatchInput input, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.textanalytics.TextAnalyticsAPI entities" }) + @POST("v2.0/entities") + Observable> entities(@Header("accept-language") String acceptLanguage, @Body MultiLanguageBatchInput input, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + } + + /** + * The API returns a list of strings denoting the key talking points in the input text. + * See the <a href="https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview#supported-languages">Text Analytics Documentation</a> for details about the languages that are supported by key phrase extraction. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the KeyPhraseBatchResultInner object if successful. + */ + public KeyPhraseBatchResultInner keyPhrases() { + return keyPhrasesWithServiceResponseAsync().toBlocking().single().body(); + } + + /** + * The API returns a list of strings denoting the key talking points in the input text. + * See the <a href="https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview#supported-languages">Text Analytics Documentation</a> for details about the languages that are supported by key phrase extraction. + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture keyPhrasesAsync(final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(keyPhrasesWithServiceResponseAsync(), serviceCallback); + } + + /** + * The API returns a list of strings denoting the key talking points in the input text. + * See the <a href="https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview#supported-languages">Text Analytics Documentation</a> for details about the languages that are supported by key phrase extraction. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the KeyPhraseBatchResultInner object + */ + public Observable keyPhrasesAsync() { + return keyPhrasesWithServiceResponseAsync().map(new Func1, KeyPhraseBatchResultInner>() { + @Override + public KeyPhraseBatchResultInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * The API returns a list of strings denoting the key talking points in the input text. + * See the <a href="https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview#supported-languages">Text Analytics Documentation</a> for details about the languages that are supported by key phrase extraction. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the KeyPhraseBatchResultInner object + */ + public Observable> keyPhrasesWithServiceResponseAsync() { + if (this.azureRegion() == null) { + throw new IllegalArgumentException("Parameter this.azureRegion() is required and cannot be null."); + } + final List documents = null; + MultiLanguageBatchInput input = new MultiLanguageBatchInput(); + input.withDocuments(null); + String parameterizedHost = Joiner.on(", ").join("{AzureRegion}", this.azureRegion()); + return service.keyPhrases(this.acceptLanguage(), input, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = keyPhrasesDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * The API returns a list of strings denoting the key talking points in the input text. + * See the <a href="https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview#supported-languages">Text Analytics Documentation</a> for details about the languages that are supported by key phrase extraction. + * + * @param documents the List<MultiLanguageInputInner> value + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the KeyPhraseBatchResultInner object if successful. + */ + public KeyPhraseBatchResultInner keyPhrases(List documents) { + return keyPhrasesWithServiceResponseAsync(documents).toBlocking().single().body(); + } + + /** + * The API returns a list of strings denoting the key talking points in the input text. + * See the <a href="https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview#supported-languages">Text Analytics Documentation</a> for details about the languages that are supported by key phrase extraction. + * + * @param documents the List<MultiLanguageInputInner> value + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture keyPhrasesAsync(List documents, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(keyPhrasesWithServiceResponseAsync(documents), serviceCallback); + } + + /** + * The API returns a list of strings denoting the key talking points in the input text. + * See the <a href="https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview#supported-languages">Text Analytics Documentation</a> for details about the languages that are supported by key phrase extraction. + * + * @param documents the List<MultiLanguageInputInner> value + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the KeyPhraseBatchResultInner object + */ + public Observable keyPhrasesAsync(List documents) { + return keyPhrasesWithServiceResponseAsync(documents).map(new Func1, KeyPhraseBatchResultInner>() { + @Override + public KeyPhraseBatchResultInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * The API returns a list of strings denoting the key talking points in the input text. + * See the <a href="https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview#supported-languages">Text Analytics Documentation</a> for details about the languages that are supported by key phrase extraction. + * + * @param documents the List<MultiLanguageInputInner> value + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the KeyPhraseBatchResultInner object + */ + public Observable> keyPhrasesWithServiceResponseAsync(List documents) { + if (this.azureRegion() == null) { + throw new IllegalArgumentException("Parameter this.azureRegion() is required and cannot be null."); + } + Validator.validate(documents); + MultiLanguageBatchInput input = new MultiLanguageBatchInput(); + input.withDocuments(documents); + String parameterizedHost = Joiner.on(", ").join("{AzureRegion}", this.azureRegion()); + return service.keyPhrases(this.acceptLanguage(), input, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = keyPhrasesDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse keyPhrasesDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.restClient().responseBuilderFactory().newInstance(this.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * The API returns the detected language and a numeric score between 0 and 1. + * Scores close to 1 indicate 100% certainty that the identified language is true. A total of 120 languages are supported. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the LanguageBatchResultInner object if successful. + */ + public LanguageBatchResultInner detectLanguage() { + return detectLanguageWithServiceResponseAsync().toBlocking().single().body(); + } + + /** + * The API returns the detected language and a numeric score between 0 and 1. + * Scores close to 1 indicate 100% certainty that the identified language is true. A total of 120 languages are supported. + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture detectLanguageAsync(final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(detectLanguageWithServiceResponseAsync(), serviceCallback); + } + + /** + * The API returns the detected language and a numeric score between 0 and 1. + * Scores close to 1 indicate 100% certainty that the identified language is true. A total of 120 languages are supported. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the LanguageBatchResultInner object + */ + public Observable detectLanguageAsync() { + return detectLanguageWithServiceResponseAsync().map(new Func1, LanguageBatchResultInner>() { + @Override + public LanguageBatchResultInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * The API returns the detected language and a numeric score between 0 and 1. + * Scores close to 1 indicate 100% certainty that the identified language is true. A total of 120 languages are supported. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the LanguageBatchResultInner object + */ + public Observable> detectLanguageWithServiceResponseAsync() { + if (this.azureRegion() == null) { + throw new IllegalArgumentException("Parameter this.azureRegion() is required and cannot be null."); + } + final List documents = null; + BatchInput input = new BatchInput(); + input.withDocuments(null); + String parameterizedHost = Joiner.on(", ").join("{AzureRegion}", this.azureRegion()); + return service.detectLanguage(this.acceptLanguage(), input, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = detectLanguageDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * The API returns the detected language and a numeric score between 0 and 1. + * Scores close to 1 indicate 100% certainty that the identified language is true. A total of 120 languages are supported. + * + * @param documents the List<InputInner> value + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the LanguageBatchResultInner object if successful. + */ + public LanguageBatchResultInner detectLanguage(List documents) { + return detectLanguageWithServiceResponseAsync(documents).toBlocking().single().body(); + } + + /** + * The API returns the detected language and a numeric score between 0 and 1. + * Scores close to 1 indicate 100% certainty that the identified language is true. A total of 120 languages are supported. + * + * @param documents the List<InputInner> value + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture detectLanguageAsync(List documents, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(detectLanguageWithServiceResponseAsync(documents), serviceCallback); + } + + /** + * The API returns the detected language and a numeric score between 0 and 1. + * Scores close to 1 indicate 100% certainty that the identified language is true. A total of 120 languages are supported. + * + * @param documents the List<InputInner> value + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the LanguageBatchResultInner object + */ + public Observable detectLanguageAsync(List documents) { + return detectLanguageWithServiceResponseAsync(documents).map(new Func1, LanguageBatchResultInner>() { + @Override + public LanguageBatchResultInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * The API returns the detected language and a numeric score between 0 and 1. + * Scores close to 1 indicate 100% certainty that the identified language is true. A total of 120 languages are supported. + * + * @param documents the List<InputInner> value + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the LanguageBatchResultInner object + */ + public Observable> detectLanguageWithServiceResponseAsync(List documents) { + if (this.azureRegion() == null) { + throw new IllegalArgumentException("Parameter this.azureRegion() is required and cannot be null."); + } + Validator.validate(documents); + BatchInput input = new BatchInput(); + input.withDocuments(documents); + String parameterizedHost = Joiner.on(", ").join("{AzureRegion}", this.azureRegion()); + return service.detectLanguage(this.acceptLanguage(), input, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = detectLanguageDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse detectLanguageDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.restClient().responseBuilderFactory().newInstance(this.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * The API returns a numeric score between 0 and 1. + * Scores close to 1 indicate positive sentiment, while scores close to 0 indicate negative sentiment. A score of 0.5 indicates the lack of sentiment (e.g. a factoid statement). See the <a href="https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview#supported-languages">Text Analytics Documentation</a> for details about the languages that are supported by sentiment analysis. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the SentimentBatchResultInner object if successful. + */ + public SentimentBatchResultInner sentiment() { + return sentimentWithServiceResponseAsync().toBlocking().single().body(); + } + + /** + * The API returns a numeric score between 0 and 1. + * Scores close to 1 indicate positive sentiment, while scores close to 0 indicate negative sentiment. A score of 0.5 indicates the lack of sentiment (e.g. a factoid statement). See the <a href="https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview#supported-languages">Text Analytics Documentation</a> for details about the languages that are supported by sentiment analysis. + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture sentimentAsync(final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(sentimentWithServiceResponseAsync(), serviceCallback); + } + + /** + * The API returns a numeric score between 0 and 1. + * Scores close to 1 indicate positive sentiment, while scores close to 0 indicate negative sentiment. A score of 0.5 indicates the lack of sentiment (e.g. a factoid statement). See the <a href="https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview#supported-languages">Text Analytics Documentation</a> for details about the languages that are supported by sentiment analysis. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the SentimentBatchResultInner object + */ + public Observable sentimentAsync() { + return sentimentWithServiceResponseAsync().map(new Func1, SentimentBatchResultInner>() { + @Override + public SentimentBatchResultInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * The API returns a numeric score between 0 and 1. + * Scores close to 1 indicate positive sentiment, while scores close to 0 indicate negative sentiment. A score of 0.5 indicates the lack of sentiment (e.g. a factoid statement). See the <a href="https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview#supported-languages">Text Analytics Documentation</a> for details about the languages that are supported by sentiment analysis. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the SentimentBatchResultInner object + */ + public Observable> sentimentWithServiceResponseAsync() { + if (this.azureRegion() == null) { + throw new IllegalArgumentException("Parameter this.azureRegion() is required and cannot be null."); + } + final List documents = null; + MultiLanguageBatchInput input = new MultiLanguageBatchInput(); + input.withDocuments(null); + String parameterizedHost = Joiner.on(", ").join("{AzureRegion}", this.azureRegion()); + return service.sentiment(this.acceptLanguage(), input, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = sentimentDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * The API returns a numeric score between 0 and 1. + * Scores close to 1 indicate positive sentiment, while scores close to 0 indicate negative sentiment. A score of 0.5 indicates the lack of sentiment (e.g. a factoid statement). See the <a href="https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview#supported-languages">Text Analytics Documentation</a> for details about the languages that are supported by sentiment analysis. + * + * @param documents the List<MultiLanguageInputInner> value + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the SentimentBatchResultInner object if successful. + */ + public SentimentBatchResultInner sentiment(List documents) { + return sentimentWithServiceResponseAsync(documents).toBlocking().single().body(); + } + + /** + * The API returns a numeric score between 0 and 1. + * Scores close to 1 indicate positive sentiment, while scores close to 0 indicate negative sentiment. A score of 0.5 indicates the lack of sentiment (e.g. a factoid statement). See the <a href="https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview#supported-languages">Text Analytics Documentation</a> for details about the languages that are supported by sentiment analysis. + * + * @param documents the List<MultiLanguageInputInner> value + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture sentimentAsync(List documents, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(sentimentWithServiceResponseAsync(documents), serviceCallback); + } + + /** + * The API returns a numeric score between 0 and 1. + * Scores close to 1 indicate positive sentiment, while scores close to 0 indicate negative sentiment. A score of 0.5 indicates the lack of sentiment (e.g. a factoid statement). See the <a href="https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview#supported-languages">Text Analytics Documentation</a> for details about the languages that are supported by sentiment analysis. + * + * @param documents the List<MultiLanguageInputInner> value + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the SentimentBatchResultInner object + */ + public Observable sentimentAsync(List documents) { + return sentimentWithServiceResponseAsync(documents).map(new Func1, SentimentBatchResultInner>() { + @Override + public SentimentBatchResultInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * The API returns a numeric score between 0 and 1. + * Scores close to 1 indicate positive sentiment, while scores close to 0 indicate negative sentiment. A score of 0.5 indicates the lack of sentiment (e.g. a factoid statement). See the <a href="https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview#supported-languages">Text Analytics Documentation</a> for details about the languages that are supported by sentiment analysis. + * + * @param documents the List<MultiLanguageInputInner> value + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the SentimentBatchResultInner object + */ + public Observable> sentimentWithServiceResponseAsync(List documents) { + if (this.azureRegion() == null) { + throw new IllegalArgumentException("Parameter this.azureRegion() is required and cannot be null."); + } + Validator.validate(documents); + MultiLanguageBatchInput input = new MultiLanguageBatchInput(); + input.withDocuments(documents); + String parameterizedHost = Joiner.on(", ").join("{AzureRegion}", this.azureRegion()); + return service.sentiment(this.acceptLanguage(), input, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = sentimentDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse sentimentDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.restClient().responseBuilderFactory().newInstance(this.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * The API returns a list of recognized entities in a given document. + * To get even more information on each recognized entity we recommend using the Bing Entity Search API by querying for the recognized entities names. See the <a href="https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/text-analytics-supported-languages">Supported languages in Text Analytics API</a> for the list of enabled languages. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the EntitiesBatchResultInner object if successful. + */ + public EntitiesBatchResultInner entities() { + return entitiesWithServiceResponseAsync().toBlocking().single().body(); + } + + /** + * The API returns a list of recognized entities in a given document. + * To get even more information on each recognized entity we recommend using the Bing Entity Search API by querying for the recognized entities names. See the <a href="https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/text-analytics-supported-languages">Supported languages in Text Analytics API</a> for the list of enabled languages. + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture entitiesAsync(final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(entitiesWithServiceResponseAsync(), serviceCallback); + } + + /** + * The API returns a list of recognized entities in a given document. + * To get even more information on each recognized entity we recommend using the Bing Entity Search API by querying for the recognized entities names. See the <a href="https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/text-analytics-supported-languages">Supported languages in Text Analytics API</a> for the list of enabled languages. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the EntitiesBatchResultInner object + */ + public Observable entitiesAsync() { + return entitiesWithServiceResponseAsync().map(new Func1, EntitiesBatchResultInner>() { + @Override + public EntitiesBatchResultInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * The API returns a list of recognized entities in a given document. + * To get even more information on each recognized entity we recommend using the Bing Entity Search API by querying for the recognized entities names. See the <a href="https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/text-analytics-supported-languages">Supported languages in Text Analytics API</a> for the list of enabled languages. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the EntitiesBatchResultInner object + */ + public Observable> entitiesWithServiceResponseAsync() { + if (this.azureRegion() == null) { + throw new IllegalArgumentException("Parameter this.azureRegion() is required and cannot be null."); + } + final List documents = null; + MultiLanguageBatchInput input = new MultiLanguageBatchInput(); + input.withDocuments(null); + String parameterizedHost = Joiner.on(", ").join("{AzureRegion}", this.azureRegion()); + return service.entities(this.acceptLanguage(), input, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = entitiesDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * The API returns a list of recognized entities in a given document. + * To get even more information on each recognized entity we recommend using the Bing Entity Search API by querying for the recognized entities names. See the <a href="https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/text-analytics-supported-languages">Supported languages in Text Analytics API</a> for the list of enabled languages. + * + * @param documents the List<MultiLanguageInputInner> value + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the EntitiesBatchResultInner object if successful. + */ + public EntitiesBatchResultInner entities(List documents) { + return entitiesWithServiceResponseAsync(documents).toBlocking().single().body(); + } + + /** + * The API returns a list of recognized entities in a given document. + * To get even more information on each recognized entity we recommend using the Bing Entity Search API by querying for the recognized entities names. See the <a href="https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/text-analytics-supported-languages">Supported languages in Text Analytics API</a> for the list of enabled languages. + * + * @param documents the List<MultiLanguageInputInner> value + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture entitiesAsync(List documents, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(entitiesWithServiceResponseAsync(documents), serviceCallback); + } + + /** + * The API returns a list of recognized entities in a given document. + * To get even more information on each recognized entity we recommend using the Bing Entity Search API by querying for the recognized entities names. See the <a href="https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/text-analytics-supported-languages">Supported languages in Text Analytics API</a> for the list of enabled languages. + * + * @param documents the List<MultiLanguageInputInner> value + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the EntitiesBatchResultInner object + */ + public Observable entitiesAsync(List documents) { + return entitiesWithServiceResponseAsync(documents).map(new Func1, EntitiesBatchResultInner>() { + @Override + public EntitiesBatchResultInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * The API returns a list of recognized entities in a given document. + * To get even more information on each recognized entity we recommend using the Bing Entity Search API by querying for the recognized entities names. See the <a href="https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/text-analytics-supported-languages">Supported languages in Text Analytics API</a> for the list of enabled languages. + * + * @param documents the List<MultiLanguageInputInner> value + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the EntitiesBatchResultInner object + */ + public Observable> entitiesWithServiceResponseAsync(List documents) { + if (this.azureRegion() == null) { + throw new IllegalArgumentException("Parameter this.azureRegion() is required and cannot be null."); + } + Validator.validate(documents); + MultiLanguageBatchInput input = new MultiLanguageBatchInput(); + input.withDocuments(documents); + String parameterizedHost = Joiner.on(", ").join("{AzureRegion}", this.azureRegion()); + return service.entities(this.acceptLanguage(), input, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = entitiesDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse entitiesDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.restClient().responseBuilderFactory().newInstance(this.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + +} diff --git a/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/implementation/package-info.java b/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/implementation/package-info.java new file mode 100644 index 00000000000..cc37d0cdb43 --- /dev/null +++ b/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/implementation/package-info.java @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** + * This package contains the implementation classes for TextAnalyticsAPI. + * The Text Analytics API is a suite of text analytics web services built with best-in-class Microsoft machine learning algorithms. The API can be used to analyze unstructured text for tasks such as sentiment analysis, key phrase extraction and language detection. No training data is needed to use this API; just bring your text data. This API uses advanced natural language processing techniques to deliver best in class predictions. Further documentation can be found in https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview. + */ +package com.microsoft.azure.cognitiveservices.textanalytics.implementation; diff --git a/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/package-info.java b/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/package-info.java new file mode 100644 index 00000000000..faac197e2a8 --- /dev/null +++ b/azure-cognitiveservices/textanalytics/src/main/java/com/microsoft/azure/cognitiveservices/textanalytics/package-info.java @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** + * This package contains the classes for TextAnalyticsAPI. + * The Text Analytics API is a suite of text analytics web services built with best-in-class Microsoft machine learning algorithms. The API can be used to analyze unstructured text for tasks such as sentiment analysis, key phrase extraction and language detection. No training data is needed to use this API; just bring your text data. This API uses advanced natural language processing techniques to deliver best in class predictions. Further documentation can be found in https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview. + */ +package com.microsoft.azure.cognitiveservices.textanalytics;