TextAnalyticsClient class

Client class for interacting with Azure Text Analytics.

Constructors

TextAnalyticsClient(string, TokenCredential | KeyCredential, TextAnalyticsClientOptions)

Creates an instance of TextAnalyticsClient.

Example usage:

import { TextAnalyticsClient, AzureKeyCredential } from "@azure/ai-text-analytics";

const client = new TextAnalyticsClient(
   "<service endpoint>",
   new AzureKeyCredential("<api key>")
);

Properties

defaultCountryHint

The default country hint to use. Defaults to "us".

defaultLanguage

The default language to use. Defaults to "en".

endpointUrl

The URL to the TextAnalytics endpoint

Methods

analyzeSentiment(string[], string, AnalyzeSentimentOptions)

Runs a predictive model to identify the positive, negative, neutral, or mixed sentiment contained in the input strings, as well as scores indicating the model's confidence in each of the predicted sentiments. Optionally it can also identify targets in the text and assessments about it through opinion mining. For a list of languages supported by this operation,

See https://docs.microsoft.com/azure/cognitive-services/text-analytics/language-support.

analyzeSentiment(TextDocumentInput[], AnalyzeSentimentOptions)

Runs a predictive model to identify the positive, negative or neutral, or mixed sentiment contained in the input documents, as well as scores indicating the model's confidence in each of the predicted sentiments.Optionally it can also identify targets in the text and assessments about it through opinion mining. For a list of languages supported by this operation,

See https://docs.microsoft.com/azure/cognitive-services/text-analytics/language-support.

beginAnalyzeActions(string[], TextAnalyticsActions, string, BeginAnalyzeActionsOptions)

Submit a collection of text documents for analysis. Specify one or more unique actions to be executed.

beginAnalyzeActions(TextDocumentInput[], TextAnalyticsActions, BeginAnalyzeActionsOptions)

Submit a collection of text documents for analysis. Specify one or more unique actions to be executed.

beginAnalyzeHealthcareEntities(string[], string, BeginAnalyzeHealthcareEntitiesOptions)

Start a healthcare analysis operation to recognize healthcare related entities (drugs, conditions, symptoms, etc) and their relations.

beginAnalyzeHealthcareEntities(TextDocumentInput[], BeginAnalyzeHealthcareEntitiesOptions)

Start a healthcare analysis operation to recognize healthcare related entities (drugs, conditions, symptoms, etc) and their relations.

detectLanguage(DetectLanguageInput[], DetectLanguageOptions)

Runs a predictive model to determine the language that the passed-in input document are written in, and returns, for each one, the detected language as well as a score indicating the model's confidence that the inferred language is correct. Scores close to 1 indicate high certainty in the result. 120 languages are supported.

detectLanguage(string[], string, DetectLanguageOptions)

Runs a predictive model to determine the language that the passed-in input strings are written in, and returns, for each one, the detected language as well as a score indicating the model's confidence that the inferred language is correct. Scores close to 1 indicate high certainty in the result. 120 languages are supported.

extractKeyPhrases(string[], string, ExtractKeyPhrasesOptions)

Runs a model to identify a collection of significant phrases found in the passed-in input strings. For a list of languages supported by this operation,

See https://docs.microsoft.com/azure/cognitive-services/text-analytics/language-support.

extractKeyPhrases(TextDocumentInput[], ExtractKeyPhrasesOptions)

Runs a model to identify a collection of significant phrases found in the passed-in input documents. For a list of languages supported by this operation,

See https://docs.microsoft.com/azure/cognitive-services/text-analytics/language-support.

recognizeEntities(string[], string, RecognizeCategorizedEntitiesOptions)

Runs a predictive model to identify a collection of named entities in the passed-in input strings, and categorize those entities into types such as person, location, or organization. For more information on available categories,

See https://docs.microsoft.com/azure/cognitive-services/Text-Analytics/named-entity-types. For a list of languages supported by this operation, See https://docs.microsoft.com/azure/cognitive-services/text-analytics/language-support.

recognizeEntities(TextDocumentInput[], RecognizeCategorizedEntitiesOptions)

Runs a predictive model to identify a collection of named entities in the passed-in input documents, and categorize those entities into types such as person, location, or organization. For more information on available categories,

See https://docs.microsoft.com/azure/cognitive-services/Text-Analytics/named-entity-types. For a list of languages supported by this operation, See https://docs.microsoft.com/azure/cognitive-services/text-analytics/language-support.

recognizeLinkedEntities(string[], string, RecognizeLinkedEntitiesOptions)

Runs a predictive model to identify a collection of entities found in the passed-in input strings, and include information linking the entities to their corresponding entries in a well-known knowledge base. For a list of languages supported by this operation,

See https://docs.microsoft.com/azure/cognitive-services/text-analytics/language-support.

recognizeLinkedEntities(TextDocumentInput[], RecognizeLinkedEntitiesOptions)

Runs a predictive model to identify a collection of entities found in the passed-in input documents, and include information linking the entities to their corresponding entries in a well-known knowledge base. For a list of languages supported by this operation,

See https://docs.microsoft.com/azure/cognitive-services/text-analytics/language-support.

recognizePiiEntities(string[], string, RecognizePiiEntitiesOptions)

Runs a predictive model to identify a collection of entities containing personally identifiable information found in the passed-in input strings, and categorize those entities into types such as US social security number, drivers license number, or credit card number. For a list of languages supported by this operation,

See https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/language-support.

recognizePiiEntities(TextDocumentInput[], RecognizePiiEntitiesOptions)

Runs a predictive model to identify a collection of entities containing personally identifiable information found in the passed-in input documents, and categorize those entities into types such as US social security number, drivers license number, or credit card number. For a list of languages supported by this operation,

See https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/language-support.

Constructor Details

TextAnalyticsClient(string, TokenCredential | KeyCredential, TextAnalyticsClientOptions)

Creates an instance of TextAnalyticsClient.

Example usage:

import { TextAnalyticsClient, AzureKeyCredential } from "@azure/ai-text-analytics";

const client = new TextAnalyticsClient(
   "<service endpoint>",
   new AzureKeyCredential("<api key>")
);
new TextAnalyticsClient(endpointUrl: string, credential: TokenCredential | KeyCredential, options?: TextAnalyticsClientOptions)

Parameters

endpointUrl

string

The URL to the TextAnalytics endpoint

credential

TokenCredential | KeyCredential

Used to authenticate requests to the service.

options
TextAnalyticsClientOptions

Used to configure the TextAnalytics client.

Property Details

defaultCountryHint

The default country hint to use. Defaults to "us".

defaultCountryHint: string

Property Value

string

defaultLanguage

The default language to use. Defaults to "en".

defaultLanguage: string

Property Value

string

endpointUrl

The URL to the TextAnalytics endpoint

endpointUrl: string

Property Value

string

Method Details

analyzeSentiment(string[], string, AnalyzeSentimentOptions)

Runs a predictive model to identify the positive, negative, neutral, or mixed sentiment contained in the input strings, as well as scores indicating the model's confidence in each of the predicted sentiments. Optionally it can also identify targets in the text and assessments about it through opinion mining. For a list of languages supported by this operation,

See https://docs.microsoft.com/azure/cognitive-services/text-analytics/language-support.

function analyzeSentiment(documents: string[], language?: string, options?: AnalyzeSentimentOptions): Promise<AnalyzeSentimentResultArray>

Parameters

documents

string[]

The input strings to analyze.

language

string

The language that all the input strings are written in. If unspecified, this value will be set to the default language in TextAnalyticsClientOptions. If set to an empty string, the service will apply a model where the lanuage is explicitly set to "None".

options
AnalyzeSentimentOptions

Optional parameters that includes enabling opinion mining.

Returns

analyzeSentiment(TextDocumentInput[], AnalyzeSentimentOptions)

Runs a predictive model to identify the positive, negative or neutral, or mixed sentiment contained in the input documents, as well as scores indicating the model's confidence in each of the predicted sentiments.Optionally it can also identify targets in the text and assessments about it through opinion mining. For a list of languages supported by this operation,

See https://docs.microsoft.com/azure/cognitive-services/text-analytics/language-support.

function analyzeSentiment(documents: TextDocumentInput[], options?: AnalyzeSentimentOptions): Promise<AnalyzeSentimentResultArray>

Parameters

documents

TextDocumentInput[]

The input documents to analyze.

options
AnalyzeSentimentOptions

Optional parameters that includes enabling opinion mining.

Returns

beginAnalyzeActions(string[], TextAnalyticsActions, string, BeginAnalyzeActionsOptions)

Submit a collection of text documents for analysis. Specify one or more unique actions to be executed.

function beginAnalyzeActions(documents: string[], actions: TextAnalyticsActions, language?: string, options?: BeginAnalyzeActionsOptions): Promise<AnalyzeActionsPollerLike>

Parameters

documents

string[]

Collection of documents to analyze

actions
TextAnalyticsActions

TextAnalyticsActions to execute.

language

string

The language that all the input strings are written in. If unspecified, this value will be set to the default language in TextAnalyticsClientOptions. If set to an empty string, the service will apply a model where the language is explicitly set to "None".

options
BeginAnalyzeActionsOptions

Options for the operation.

Returns

beginAnalyzeActions(TextDocumentInput[], TextAnalyticsActions, BeginAnalyzeActionsOptions)

Submit a collection of text documents for analysis. Specify one or more unique actions to be executed.

function beginAnalyzeActions(documents: TextDocumentInput[], actions: TextAnalyticsActions, options?: BeginAnalyzeActionsOptions): Promise<AnalyzeActionsPollerLike>

Parameters

documents

TextDocumentInput[]

Collection of documents to analyze

actions
TextAnalyticsActions

TextAnalyticsActions to execute.

options
BeginAnalyzeActionsOptions

Options for the operation.

Returns

beginAnalyzeHealthcareEntities(string[], string, BeginAnalyzeHealthcareEntitiesOptions)

Start a healthcare analysis operation to recognize healthcare related entities (drugs, conditions, symptoms, etc) and their relations.

function beginAnalyzeHealthcareEntities(documents: string[], language?: string, options?: BeginAnalyzeHealthcareEntitiesOptions): Promise<AnalyzeHealthcareEntitiesPollerLike>

Parameters

documents

string[]

Collection of documents to analyze.

language

string

The language that all the input strings are written in. If unspecified, this value will be set to the default language in TextAnalyticsClientOptions. If set to an empty string, the service will apply a model where the language is explicitly set to "None".

options
BeginAnalyzeHealthcareEntitiesOptions

Options for the operation.

Returns

beginAnalyzeHealthcareEntities(TextDocumentInput[], BeginAnalyzeHealthcareEntitiesOptions)

Start a healthcare analysis operation to recognize healthcare related entities (drugs, conditions, symptoms, etc) and their relations.

function beginAnalyzeHealthcareEntities(documents: TextDocumentInput[], options?: BeginAnalyzeHealthcareEntitiesOptions): Promise<AnalyzeHealthcareEntitiesPollerLike>

Parameters

documents

TextDocumentInput[]

Collection of documents to analyze.

options
BeginAnalyzeHealthcareEntitiesOptions

Options for the operation.

Returns

detectLanguage(DetectLanguageInput[], DetectLanguageOptions)

Runs a predictive model to determine the language that the passed-in input document are written in, and returns, for each one, the detected language as well as a score indicating the model's confidence that the inferred language is correct. Scores close to 1 indicate high certainty in the result. 120 languages are supported.

function detectLanguage(documents: DetectLanguageInput[], options?: DetectLanguageOptions): Promise<DetectLanguageResultArray>

Parameters

documents

DetectLanguageInput[]

A collection of input documents to analyze.

options
DetectLanguageOptions

Optional parameters for the operation.

Returns

detectLanguage(string[], string, DetectLanguageOptions)

Runs a predictive model to determine the language that the passed-in input strings are written in, and returns, for each one, the detected language as well as a score indicating the model's confidence that the inferred language is correct. Scores close to 1 indicate high certainty in the result. 120 languages are supported.

function detectLanguage(documents: string[], countryHint?: string, options?: DetectLanguageOptions): Promise<DetectLanguageResultArray>

Parameters

documents

string[]

A collection of input strings to analyze.

countryHint

string

Indicates the country of origin for all of the input strings to assist the text analytics model in predicting the language they are written in. If unspecified, this value will be set to the default country hint in TextAnalyticsClientOptions. If set to an empty string, or the string "none", the service will apply a model where the country is explicitly unset. The same country hint is applied to all strings in the input collection.

options
DetectLanguageOptions

Optional parameters for the operation.

Returns

extractKeyPhrases(string[], string, ExtractKeyPhrasesOptions)

Runs a model to identify a collection of significant phrases found in the passed-in input strings. For a list of languages supported by this operation,

See https://docs.microsoft.com/azure/cognitive-services/text-analytics/language-support.

function extractKeyPhrases(documents: string[], language?: string, options?: ExtractKeyPhrasesOptions): Promise<ExtractKeyPhrasesResultArray>

Parameters

documents

string[]

The input strings to analyze.

language

string

The language that all the input strings are written in. If unspecified, this value will be set to the default language in TextAnalyticsClientOptions. If set to an empty string, the service will apply a model where the language is explicitly set to "None".

options
ExtractKeyPhrasesOptions

Options for the operation.

Returns

extractKeyPhrases(TextDocumentInput[], ExtractKeyPhrasesOptions)

Runs a model to identify a collection of significant phrases found in the passed-in input documents. For a list of languages supported by this operation,

See https://docs.microsoft.com/azure/cognitive-services/text-analytics/language-support.

function extractKeyPhrases(documents: TextDocumentInput[], options?: ExtractKeyPhrasesOptions): Promise<ExtractKeyPhrasesResultArray>

Parameters

documents

TextDocumentInput[]

The input documents to analyze.

options
ExtractKeyPhrasesOptions

Options for the operation.

Returns

recognizeEntities(string[], string, RecognizeCategorizedEntitiesOptions)

Runs a predictive model to identify a collection of named entities in the passed-in input strings, and categorize those entities into types such as person, location, or organization. For more information on available categories,

See https://docs.microsoft.com/azure/cognitive-services/Text-Analytics/named-entity-types. For a list of languages supported by this operation, See https://docs.microsoft.com/azure/cognitive-services/text-analytics/language-support.

function recognizeEntities(documents: string[], language?: string, options?: RecognizeCategorizedEntitiesOptions): Promise<RecognizeCategorizedEntitiesResultArray>

Parameters

documents

string[]

The input strings to analyze.

language

string

The language that all the input strings are written in. If unspecified, this value will be set to the default language in TextAnalyticsClientOptions. If set to an empty string, the service will apply a model where the language is explicitly set to "None".

options
RecognizeCategorizedEntitiesOptions

Optional parameters for the operation.

Returns

recognizeEntities(TextDocumentInput[], RecognizeCategorizedEntitiesOptions)

Runs a predictive model to identify a collection of named entities in the passed-in input documents, and categorize those entities into types such as person, location, or organization. For more information on available categories,

See https://docs.microsoft.com/azure/cognitive-services/Text-Analytics/named-entity-types. For a list of languages supported by this operation, See https://docs.microsoft.com/azure/cognitive-services/text-analytics/language-support.

function recognizeEntities(documents: TextDocumentInput[], options?: RecognizeCategorizedEntitiesOptions): Promise<RecognizeCategorizedEntitiesResultArray>

Parameters

documents

TextDocumentInput[]

The input documents to analyze.

options
RecognizeCategorizedEntitiesOptions

Optional parameters for the operation.

Returns

recognizeLinkedEntities(string[], string, RecognizeLinkedEntitiesOptions)

Runs a predictive model to identify a collection of entities found in the passed-in input strings, and include information linking the entities to their corresponding entries in a well-known knowledge base. For a list of languages supported by this operation,

See https://docs.microsoft.com/azure/cognitive-services/text-analytics/language-support.

function recognizeLinkedEntities(documents: string[], language?: string, options?: RecognizeLinkedEntitiesOptions): Promise<RecognizeLinkedEntitiesResultArray>

Parameters

documents

string[]

The input strings to analyze.

language

string

The language that all the input strings are written in. If unspecified, this value will be set to the default language in TextAnalyticsClientOptions. If set to an empty string, the service will apply a model where the language is explicitly set to "None".

options
RecognizeLinkedEntitiesOptions

Options for the operation.

Returns

recognizeLinkedEntities(TextDocumentInput[], RecognizeLinkedEntitiesOptions)

Runs a predictive model to identify a collection of entities found in the passed-in input documents, and include information linking the entities to their corresponding entries in a well-known knowledge base. For a list of languages supported by this operation,

See https://docs.microsoft.com/azure/cognitive-services/text-analytics/language-support.

function recognizeLinkedEntities(documents: TextDocumentInput[], options?: RecognizeLinkedEntitiesOptions): Promise<RecognizeLinkedEntitiesResultArray>

Parameters

documents

TextDocumentInput[]

The input documents to analyze.

options
RecognizeLinkedEntitiesOptions

Options for the operation.

Returns

recognizePiiEntities(string[], string, RecognizePiiEntitiesOptions)

Runs a predictive model to identify a collection of entities containing personally identifiable information found in the passed-in input strings, and categorize those entities into types such as US social security number, drivers license number, or credit card number. For a list of languages supported by this operation,

See https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/language-support.

function recognizePiiEntities(inputs: string[], language?: string, options?: RecognizePiiEntitiesOptions): Promise<RecognizePiiEntitiesResultArray>

Parameters

inputs

string[]

The input strings to analyze.

language

string

The language that all the input strings are written in. If unspecified, this value will be set to the default language in TextAnalyticsClientOptions. If set to an empty string, the service will apply a model where the language is explicitly set to "None".

options
RecognizePiiEntitiesOptions

Options for the operation.

Returns

recognizePiiEntities(TextDocumentInput[], RecognizePiiEntitiesOptions)

Runs a predictive model to identify a collection of entities containing personally identifiable information found in the passed-in input documents, and categorize those entities into types such as US social security number, drivers license number, or credit card number. For a list of languages supported by this operation,

See https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/language-support.

function recognizePiiEntities(inputs: TextDocumentInput[], options?: RecognizePiiEntitiesOptions): Promise<RecognizePiiEntitiesResultArray>

Parameters

inputs

TextDocumentInput[]

The input documents to analyze.

options
RecognizePiiEntitiesOptions

Optional parameters for the operation.

Returns