diff --git a/profiles/latest/cognitiveservices/textanalytics/models.go b/profiles/latest/cognitiveservices/textanalytics/models.go
index e0cb1a8641d4..64cf7df40570 100644
--- a/profiles/latest/cognitiveservices/textanalytics/models.go
+++ b/profiles/latest/cognitiveservices/textanalytics/models.go
@@ -41,6 +41,9 @@ const (
type BatchInput = original.BatchInput
type DetectedLanguage = original.DetectedLanguage
+type EntitiesBatchResult = original.EntitiesBatchResult
+type EntitiesBatchResultItem = original.EntitiesBatchResultItem
+type EntityRecord = original.EntityRecord
type ErrorRecord = original.ErrorRecord
type ErrorResponse = original.ErrorResponse
type Input = original.Input
@@ -49,6 +52,7 @@ type KeyPhraseBatchResult = original.KeyPhraseBatchResult
type KeyPhraseBatchResultItem = original.KeyPhraseBatchResultItem
type LanguageBatchResult = original.LanguageBatchResult
type LanguageBatchResultItem = original.LanguageBatchResultItem
+type MatchRecord = original.MatchRecord
type MultiLanguageBatchInput = original.MultiLanguageBatchInput
type MultiLanguageInput = original.MultiLanguageInput
type SentimentBatchResult = original.SentimentBatchResult
diff --git a/profiles/preview/cognitiveservices/textanalytics/models.go b/profiles/preview/cognitiveservices/textanalytics/models.go
index 276ee9272abe..4501c72ac9d8 100644
--- a/profiles/preview/cognitiveservices/textanalytics/models.go
+++ b/profiles/preview/cognitiveservices/textanalytics/models.go
@@ -41,6 +41,9 @@ const (
type BatchInput = original.BatchInput
type DetectedLanguage = original.DetectedLanguage
+type EntitiesBatchResult = original.EntitiesBatchResult
+type EntitiesBatchResultItem = original.EntitiesBatchResultItem
+type EntityRecord = original.EntityRecord
type ErrorRecord = original.ErrorRecord
type ErrorResponse = original.ErrorResponse
type Input = original.Input
@@ -49,6 +52,7 @@ type KeyPhraseBatchResult = original.KeyPhraseBatchResult
type KeyPhraseBatchResultItem = original.KeyPhraseBatchResultItem
type LanguageBatchResult = original.LanguageBatchResult
type LanguageBatchResultItem = original.LanguageBatchResultItem
+type MatchRecord = original.MatchRecord
type MultiLanguageBatchInput = original.MultiLanguageBatchInput
type MultiLanguageInput = original.MultiLanguageInput
type SentimentBatchResult = original.SentimentBatchResult
diff --git a/services/cognitiveservices/v2.0/textanalytics/client.go b/services/cognitiveservices/v2.0/textanalytics/client.go
index 31ebe2676c64..5fbde4c666ad 100644
--- a/services/cognitiveservices/v2.0/textanalytics/client.go
+++ b/services/cognitiveservices/v2.0/textanalytics/client.go
@@ -52,8 +52,8 @@ func NewWithoutDefaults(azureRegion AzureRegions) BaseClient {
// DetectLanguage scores close to 1 indicate 100% certainty that the identified language is true. A total of 120
// languages are supported.
-// Parameters:
-// input - collection of documents to analyze.
+//
+// input is collection of documents to analyze.
func (client BaseClient) DetectLanguage(ctx context.Context, input BatchInput) (result LanguageBatchResult, err error) {
req, err := client.DetectLanguagePreparer(ctx, input)
if err != nil {
@@ -111,11 +111,74 @@ func (client BaseClient) DetectLanguageResponder(resp *http.Response) (result La
return
}
-// KeyPhrases we employ techniques from Microsoft Office's sophisticated Natural Language Processing toolkit. See the
-// Text
+// Entities 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 Supported
+// languages in Text Analytics API for the list of enabled languages.
+//
+// input is collection of documents to analyze.
+func (client BaseClient) Entities(ctx context.Context, input MultiLanguageBatchInput) (result EntitiesBatchResult, err error) {
+ req, err := client.EntitiesPreparer(ctx, input)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "textanalytics.BaseClient", "Entities", nil, "Failure preparing request")
+ return
+ }
+
+ resp, err := client.EntitiesSender(req)
+ if err != nil {
+ result.Response = autorest.Response{Response: resp}
+ err = autorest.NewErrorWithError(err, "textanalytics.BaseClient", "Entities", resp, "Failure sending request")
+ return
+ }
+
+ result, err = client.EntitiesResponder(resp)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "textanalytics.BaseClient", "Entities", resp, "Failure responding to request")
+ }
+
+ return
+}
+
+// EntitiesPreparer prepares the Entities request.
+func (client BaseClient) EntitiesPreparer(ctx context.Context, input MultiLanguageBatchInput) (*http.Request, error) {
+ urlParameters := map[string]interface{}{
+ "AzureRegion": client.AzureRegion,
+ }
+
+ preparer := autorest.CreatePreparer(
+ autorest.AsContentType("application/json; charset=utf-8"),
+ autorest.AsPost(),
+ autorest.WithCustomBaseURL("https://{AzureRegion}.api.cognitive.microsoft.com/text/analytics", urlParameters),
+ autorest.WithPath("/v2.0/entities"),
+ autorest.WithJSON(input))
+ return preparer.Prepare((&http.Request{}).WithContext(ctx))
+}
+
+// EntitiesSender sends the Entities request. The method will close the
+// http.Response Body if it receives an error.
+func (client BaseClient) EntitiesSender(req *http.Request) (*http.Response, error) {
+ return autorest.SendWithSender(client, req,
+ autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
+}
+
+// EntitiesResponder handles the response to the Entities request. The method always
+// closes the http.Response Body.
+func (client BaseClient) EntitiesResponder(resp *http.Response) (result EntitiesBatchResult, err error) {
+ err = autorest.Respond(
+ resp,
+ client.ByInspecting(),
+ azure.WithErrorUnlessStatusCode(http.StatusOK),
+ autorest.ByUnmarshallingJSON(&result),
+ autorest.ByClosing())
+ result.Response = autorest.Response{Response: resp}
+ return
+}
+
+// KeyPhrases see the Text
// Analytics Documentation for details about the languages that are supported by key phrase extraction.
-// Parameters:
-// input - collection of documents to analyze. Documents can now contain a language field to indicate the text
+//
+// input is collection of documents to analyze. Documents can now contain a language field to indicate the text
// language
func (client BaseClient) KeyPhrases(ctx context.Context, input MultiLanguageBatchInput) (result KeyPhraseBatchResult, err error) {
req, err := client.KeyPhrasesPreparer(ctx, input)
@@ -174,13 +237,12 @@ func (client BaseClient) KeyPhrasesResponder(resp *http.Response) (result KeyPhr
return
}
-// Sentiment scores close to 1 indicate positive sentiment, while scores close to 0 indicate negative sentiment.
-// Sentiment score is generated using classification techniques. The input features to the classifier include n-grams,
-// features generated from part-of-speech tags, and word embeddings. See the Text
// Analytics Documentation for details about the languages that are supported by sentiment analysis.
-// Parameters:
-// input - collection of documents to analyze.
+//
+// input is collection of documents to analyze.
func (client BaseClient) Sentiment(ctx context.Context, input MultiLanguageBatchInput) (result SentimentBatchResult, err error) {
req, err := client.SentimentPreparer(ctx, input)
if err != nil {
diff --git a/services/cognitiveservices/v2.0/textanalytics/models.go b/services/cognitiveservices/v2.0/textanalytics/models.go
index 8b791b18356b..e688fafaac9f 100644
--- a/services/cognitiveservices/v2.0/textanalytics/models.go
+++ b/services/cognitiveservices/v2.0/textanalytics/models.go
@@ -71,6 +71,37 @@ type DetectedLanguage struct {
Score *float64 `json:"score,omitempty"`
}
+// EntitiesBatchResult ...
+type EntitiesBatchResult struct {
+ autorest.Response `json:"-"`
+ Documents *[]EntitiesBatchResultItem `json:"documents,omitempty"`
+ Errors *[]ErrorRecord `json:"errors,omitempty"`
+}
+
+// EntitiesBatchResultItem ...
+type EntitiesBatchResultItem struct {
+ // ID - Unique document identifier.
+ ID *string `json:"id,omitempty"`
+ // Entities - Recognized entities in the document.
+ Entities *[]EntityRecord `json:"entities,omitempty"`
+}
+
+// EntityRecord ...
+type EntityRecord struct {
+ // Name - Entity formal name.
+ Name *string `json:"name,omitempty"`
+ // Matches - List of instances this entity appears in the text.
+ Matches *[]MatchRecord `json:"matches,omitempty"`
+ // WikipediaLanguage - Wikipedia language for which the WikipediaId and WikipediaUrl refers to.
+ WikipediaLanguage *string `json:"wikipediaLanguage,omitempty"`
+ // WikipediaID - Wikipedia unique identifier of the recognized entity.
+ WikipediaID *string `json:"wikipediaId,omitempty"`
+ // WikipediaURL - URL for the entity's English Wikipedia page.
+ WikipediaURL *string `json:"wikipediaUrl,omitempty"`
+ // BingID - Bing unique identifier of the recognized entity. Use in conjunction with the Bing Entity Search API to fetch additional relevant information.
+ BingID *string `json:"bingId,omitempty"`
+}
+
// ErrorRecord ...
type ErrorRecord struct {
// ID - Input document unique identifier the error refers to.
@@ -131,6 +162,16 @@ type LanguageBatchResultItem struct {
DetectedLanguages *[]DetectedLanguage `json:"detectedLanguages,omitempty"`
}
+// MatchRecord ...
+type MatchRecord struct {
+ // Text - Entity text as appears in the request.
+ Text *string `json:"text,omitempty"`
+ // Offset - Start position (in Unicode characters) for the entity match text.
+ Offset *int32 `json:"offset,omitempty"`
+ // Length - Length (in Unicode characters) for the entity match text.
+ Length *int32 `json:"length,omitempty"`
+}
+
// MultiLanguageBatchInput ...
type MultiLanguageBatchInput struct {
Documents *[]MultiLanguageInput `json:"documents,omitempty"`