Module azure.textanalytics

ballerinax/azure.textanalytics Ballerina library

2.0.0

Overview

Azure Text Analytics is a suite of natural language processing (NLP) services built with Microsoft machine learning algorithms. It analyzes unstructured text for tasks such as sentiment analysis, key phrase extraction, language detection and entity recognition, with additional support for healthcare and personal information analysis.

The Azure Text Analytics connector lets Ballerina applications call the Text Analytics REST API, version 3.1.

Key features

  • Detect the language of text documents
  • Analyze sentiment, including opinion mining at sentence and target level
  • Extract key phrases from unstructured text
  • Recognize named entities, personal information and linked entities from a knowledge base
  • Run long-running analysis and healthcare jobs and track their status

Setup guide

To use the connector you need an Azure Cognitive Services Language (Text Analytics) resource.

  1. Sign in to the Azure portal and create a Language resource.

  2. Open the resource and select Keys and Endpoint.

  3. Copy one of the subscription keys and the endpoint. The connector sends the key in the Ocp-Apim-Subscription-Key header.

Quickstart

To use the Azure Text Analytics connector in your Ballerina application, update the .bal file as follows.

Step 1: Import the connector.

Copy
import ballerinax/azure.textanalytics;

Step 2: Create a Config.toml file with your subscription key and endpoint.

Copy
subscriptionKey = "<subscription key>"
serviceUrl = "<endpoint>/text/analytics/v3.1"

Step 3: Create a client.

Copy
configurable string subscriptionKey = ?;
configurable string serviceUrl = ?;

textanalytics:Client textAnalytics = check new ({ocpApimSubscriptionKey: subscriptionKey}, serviceUrl = serviceUrl);

Step 4: Detect the language of a document.

Copy
public function main() returns error? {
    textanalytics:LanguageResult _ = check textAnalytics->detectLanguage({
        documents: [{id: "1", text: "Hello world"}]
    });
}

Examples

The Azure Text Analytics connector provides practical examples illustrating usage in various scenarios. Explore these examples, covering the following use cases:

Import

import ballerinax/azure.textanalytics;Copy

Other versions

See more...

Metadata

Released date: 1 day ago

Version: 2.0.0

License: Apache-2.0


Security

Direct vulnerabilities: No known direct vulnerabilities

Indirect vulnerabilities: 

Checked on 2026-11-21 via OSV.dev


Compatibility

Platform: any

Ballerina version: 2201.12.0

GraalVM compatible: Yes


Pull count

Total: 108

Current verison: 1


Weekly downloads


Source repository


Keywords

Vendor/Microsoft

Area/AI & Machine Learning

Type/Connector


Contributors