azure-ai-textanalytics-py

Azure AI Text Analytics SDK for sentiment analysis, entity recognition, key phrases, language detection, PII, and healthcare NLP. Use for natural language processing on text.

31,392 stars
Complexity: medium

About this skill

This skill provides a robust interface to Azure AI Language (formerly Azure AI Text Analytics) services, empowering AI agents with advanced natural language processing (NLP) capabilities. It allows for the analysis of unstructured text to extract valuable insights, including: * **Sentiment Analysis:** Determine the emotional tone (positive, negative, neutral, mixed) of text at the document and sentence level. * **Entity Recognition:** Identify and categorize named entities such as people, places, organizations, events, and more. * **Key Phrase Extraction:** Automatically identify the main concepts and topics within a document. * **Language Detection:** Accurately detect the language of the input text. * **Personally Identifiable Information (PII) Detection:** Locate and categorize sensitive information like email addresses, phone numbers, and names to aid in compliance and data redaction. * **Healthcare NLP:** Perform specialized analysis on clinical text to extract medical concepts, relationships, and PII specific to the healthcare domain. Leveraging the Python SDK for Azure AI Language, this skill requires proper authentication with an Azure endpoint and an API key, enabling seamless integration with cloud-based Azure AI services.

Best use case

Analyzing customer reviews, social media posts, or survey responses for sentiment and trending topics. Automating information extraction from legal documents, news articles, or research papers. Detecting and redacting sensitive data (PII/PHI) in text for privacy compliance. Categorizing and routing incoming text-based support tickets, emails, or chat messages based on content and language. Gaining deeper insights from clinical notes or medical reports in the healthcare sector.

Azure AI Text Analytics SDK for sentiment analysis, entity recognition, key phrases, language detection, PII, and healthcare NLP. Use for natural language processing on text.

Structured and categorized insights derived from unstructured text, including sentiment scores, lists of identified entities with categories, extracted key phrases, detected language codes, and detailed information about detected PII/PHI, enabling the AI agent to take informed actions or present summarized data.

Practical example

Example input

Analyze the following text: 'The new quantum widget is amazing, but their customer support, specifically Jane Doe, was incredibly slow to respond to my query about the serial number ABC-123. Please keep my email sickn33@example.com private.' for sentiment, entities, key phrases, PII, and language.

Example output

```json
{
  "language": "en",
  "sentiment": {
    "overall": "mixed",
    "sentences": [
      {"text": "The new quantum widget is amazing", "sentiment": "positive", "confidence": {"positive": 0.95, "neutral": 0.04, "negative": 0.01}},
      {"text": "their customer support, specifically Jane Doe, was incredibly slow to respond to my query about the serial number ABC-123", "sentiment": "negative", "confidence": {"positive": 0.05, "neutral": 0.15, "negative": 0.80}},
      {"text": "Please keep my email sickn33@example.com private.", "sentiment": "neutral", "confidence": {"positive": 0.10, "neutral": 0.85, "negative": 0.05}}
    ]
  },
  "entities": [
    {"text": "quantum widget", "category": "Product"},
    {"text": "customer support", "category": "Organization"},
    {"text": "Jane Doe", "category": "Person"},
    {"text": "ABC-123", "category": "Quantity", "subcategory": "Serial Number"}
  ],
  "key_phrases": [
    "new quantum widget",
    "customer support",
    "Jane Doe",
    "query",
    "serial number"
  ],
  "pii_entities": [
    {"text": "Jane Doe", "category": "Person"},
    {"text": "ABC-123", "category": "Quantity", "subcategory": "Serial Number"},
    {"text": "sickn33@example.com", "category": "Email"}
  ]
}
```

When to use this skill

  • When you need to perform comprehensive natural language understanding on large volumes of text data.
  • When integrating with Azure cloud services and requiring a scalable, enterprise-grade NLP solution.
  • When compliance with data privacy regulations (e.g., GDPR, HIPAA) requires automated PII detection and handling.
  • When an AI agent needs to interpret, summarize, or extract specific structured information from unstructured text inputs.

When not to use this skill

  • For extremely simple text operations that do not require advanced NLP models (e.g., basic string searching or counting).
  • When an offline-only or entirely on-device NLP solution is a strict requirement due to connectivity or latency constraints.
  • When budget limitations preclude the use of cloud-based AI services, which incur usage-based costs.
  • If you have already developed or acquired a highly specialized, custom NLP model that significantly outperforms general-purpose services for your niche domain.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/azure-ai-textanalytics-py/SKILL.md --create-dirs "https://raw.githubusercontent.com/sickn33/antigravity-awesome-skills/main/plugins/antigravity-awesome-skills-claude/skills/azure-ai-textanalytics-py/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/azure-ai-textanalytics-py/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How azure-ai-textanalytics-py Compares

Feature / Agentazure-ai-textanalytics-pyStandard Approach
Platform SupportClaudeLimited / Varies
Context Awareness High Baseline
Installation ComplexitymediumN/A

Frequently Asked Questions

What does this skill do?

Azure AI Text Analytics SDK for sentiment analysis, entity recognition, key phrases, language detection, PII, and healthcare NLP. Use for natural language processing on text.

Which AI agents support this skill?

This skill is designed for Claude.

How difficult is it to install?

The installation complexity is rated as medium. You can find the installation instructions above.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

Related Guides

SKILL.md Source

# Azure AI Text Analytics SDK for Python

Client library for Azure AI Language service NLP capabilities including sentiment, entities, key phrases, and more.

## Installation

```bash
pip install azure-ai-textanalytics
```

## Environment Variables

```bash
AZURE_LANGUAGE_ENDPOINT=https://<resource>.cognitiveservices.azure.com
AZURE_LANGUAGE_KEY=<your-api-key>  # If using API key
```

## Authentication

### API Key

```python
import os
from azure.core.credentials import AzureKeyCredential
from azure.ai.textanalytics import TextAnalyticsClient

endpoint = os.environ["AZURE_LANGUAGE_ENDPOINT"]
key = os.environ["AZURE_LANGUAGE_KEY"]

client = TextAnalyticsClient(endpoint, AzureKeyCredential(key))
```

### Entra ID (Recommended)

```python
from azure.ai.textanalytics import TextAnalyticsClient
from azure.identity import DefaultAzureCredential

client = TextAnalyticsClient(
    endpoint=os.environ["AZURE_LANGUAGE_ENDPOINT"],
    credential=DefaultAzureCredential()
)
```

## Sentiment Analysis

```python
documents = [
    "I had a wonderful trip to Seattle last week!",
    "The food was terrible and the service was slow."
]

result = client.analyze_sentiment(documents, show_opinion_mining=True)

for doc in result:
    if not doc.is_error:
        print(f"Sentiment: {doc.sentiment}")
        print(f"Scores: pos={doc.confidence_scores.positive:.2f}, "
              f"neg={doc.confidence_scores.negative:.2f}, "
              f"neu={doc.confidence_scores.neutral:.2f}")
        
        # Opinion mining (aspect-based sentiment)
        for sentence in doc.sentences:
            for opinion in sentence.mined_opinions:
                target = opinion.target
                print(f"  Target: '{target.text}' - {target.sentiment}")
                for assessment in opinion.assessments:
                    print(f"    Assessment: '{assessment.text}' - {assessment.sentiment}")
```

## Entity Recognition

```python
documents = ["Microsoft was founded by Bill Gates and Paul Allen in Albuquerque."]

result = client.recognize_entities(documents)

for doc in result:
    if not doc.is_error:
        for entity in doc.entities:
            print(f"Entity: {entity.text}")
            print(f"  Category: {entity.category}")
            print(f"  Subcategory: {entity.subcategory}")
            print(f"  Confidence: {entity.confidence_score:.2f}")
```

## PII Detection

```python
documents = ["My SSN is 123-45-6789 and my email is john@example.com"]

result = client.recognize_pii_entities(documents)

for doc in result:
    if not doc.is_error:
        print(f"Redacted: {doc.redacted_text}")
        for entity in doc.entities:
            print(f"PII: {entity.text} ({entity.category})")
```

## Key Phrase Extraction

```python
documents = ["Azure AI provides powerful machine learning capabilities for developers."]

result = client.extract_key_phrases(documents)

for doc in result:
    if not doc.is_error:
        print(f"Key phrases: {doc.key_phrases}")
```

## Language Detection

```python
documents = ["Ce document est en francais.", "This is written in English."]

result = client.detect_language(documents)

for doc in result:
    if not doc.is_error:
        print(f"Language: {doc.primary_language.name} ({doc.primary_language.iso6391_name})")
        print(f"Confidence: {doc.primary_language.confidence_score:.2f}")
```

## Healthcare Text Analytics

```python
documents = ["Patient has diabetes and was prescribed metformin 500mg twice daily."]

poller = client.begin_analyze_healthcare_entities(documents)
result = poller.result()

for doc in result:
    if not doc.is_error:
        for entity in doc.entities:
            print(f"Entity: {entity.text}")
            print(f"  Category: {entity.category}")
            print(f"  Normalized: {entity.normalized_text}")
            
            # Entity links (UMLS, etc.)
            for link in entity.data_sources:
                print(f"  Link: {link.name} - {link.entity_id}")
```

## Multiple Analysis (Batch)

```python
from azure.ai.textanalytics import (
    RecognizeEntitiesAction,
    ExtractKeyPhrasesAction,
    AnalyzeSentimentAction
)

documents = ["Microsoft announced new Azure AI features at Build conference."]

poller = client.begin_analyze_actions(
    documents,
    actions=[
        RecognizeEntitiesAction(),
        ExtractKeyPhrasesAction(),
        AnalyzeSentimentAction()
    ]
)

results = poller.result()
for doc_results in results:
    for result in doc_results:
        if result.kind == "EntityRecognition":
            print(f"Entities: {[e.text for e in result.entities]}")
        elif result.kind == "KeyPhraseExtraction":
            print(f"Key phrases: {result.key_phrases}")
        elif result.kind == "SentimentAnalysis":
            print(f"Sentiment: {result.sentiment}")
```

## Async Client

```python
from azure.ai.textanalytics.aio import TextAnalyticsClient
from azure.identity.aio import DefaultAzureCredential

async def analyze():
    async with TextAnalyticsClient(
        endpoint=endpoint,
        credential=DefaultAzureCredential()
    ) as client:
        result = await client.analyze_sentiment(documents)
        # Process results...
```

## Client Types

| Client | Purpose |
|--------|---------|
| `TextAnalyticsClient` | All text analytics operations |
| `TextAnalyticsClient` (aio) | Async version |

## Available Operations

| Method | Description |
|--------|-------------|
| `analyze_sentiment` | Sentiment analysis with opinion mining |
| `recognize_entities` | Named entity recognition |
| `recognize_pii_entities` | PII detection and redaction |
| `recognize_linked_entities` | Entity linking to Wikipedia |
| `extract_key_phrases` | Key phrase extraction |
| `detect_language` | Language detection |
| `begin_analyze_healthcare_entities` | Healthcare NLP (long-running) |
| `begin_analyze_actions` | Multiple analyses in batch |

## Best Practices

1. **Use batch operations** for multiple documents (up to 10 per request)
2. **Enable opinion mining** for detailed aspect-based sentiment
3. **Use async client** for high-throughput scenarios
4. **Handle document errors** — results list may contain errors for some docs
5. **Specify language** when known to improve accuracy
6. **Use context manager** or close client explicitly

## When to Use
This skill is applicable to execute the workflow or actions described in the overview.

Related Skills

azure-search-documents-py

31392
from sickn33/antigravity-awesome-skills

Azure AI Search SDK for Python. Use for vector search, hybrid search, semantic ranking, indexing, and skillsets.

Text AnalysisClaude

keyword-extractor

31392
from sickn33/antigravity-awesome-skills

Extracts up to 50 highly relevant SEO keywords from text. Use when user wants to generate or extract keywords for given text.

Text AnalysisClaude

hugging-face-papers

31392
from sickn33/antigravity-awesome-skills

Read and analyze Hugging Face paper pages or arXiv papers with markdown and papers API metadata.

Text AnalysisClaude

flutter-expert

31392
from sickn33/antigravity-awesome-skills

Master Flutter development with Dart 3, advanced widgets, and multi-platform deployment.

Text AnalysisClaude

docs-architect

31392
from sickn33/antigravity-awesome-skills

Creates comprehensive technical documentation from existing codebases. Analyzes architecture, design patterns, and implementation details to produce long-form technical manuals and ebooks.

Text AnalysisClaude

data-storytelling

31392
from sickn33/antigravity-awesome-skills

Transform raw data into compelling narratives that drive decisions and inspire action.

Text AnalysisClaude

data-engineering-data-pipeline

31392
from sickn33/antigravity-awesome-skills

You are a data pipeline architecture expert specializing in scalable, reliable, and cost-effective data pipelines for batch and streaming data processing.

Text AnalysisClaude

behavioral-modes

31392
from sickn33/antigravity-awesome-skills

AI operational modes (brainstorm, implement, debug, review, teach, ship, orchestrate). Use to adapt behavior based on task type.

Text AnalysisClaude

microsoft-azure-webjobs-extensions-authentication-events-dotnet

31392
from sickn33/antigravity-awesome-skills

Microsoft Entra Authentication Events SDK for .NET. Azure Functions triggers for custom authentication extensions.

Identity Management / Authentication & AuthorizationClaude

azure-web-pubsub-ts

31392
from sickn33/antigravity-awesome-skills

Real-time messaging with WebSocket connections and pub/sub patterns.

Messaging & CommunicationClaude

azure-storage-queue-ts

31392
from sickn33/antigravity-awesome-skills

Azure Queue Storage JavaScript/TypeScript SDK (@azure/storage-queue) for message queue operations. Use for sending, receiving, peeking, and deleting messages in queues.

Cloud IntegrationClaude

azure-storage-queue-py

31392
from sickn33/antigravity-awesome-skills

Azure Queue Storage SDK for Python. Use for reliable message queuing, task distribution, and asynchronous processing.

Cloud IntegrationClaude