Key Phrase Extraction

Overview

Key phrase extraction identifies the most relevant phrases in a document, helping you understand the main topics without reading the entire text. Azure Language Service provides a scalable REST API that extracts key phrases in multiple languages.

Getting Started

1. Create a Language Service resource in the Azure portal.

2. Retrieve your Endpoint and API key from the resource's Keys and Endpoint page.

3. Install the Azure SDK or call the REST endpoint directly.

Quickstart (Python)

pip install azure-ai-language
import os
from azure.ai.language import TextAnalyticsClient
from azure.core.credentials import AzureKeyCredential

endpoint = os.getenv("LANGUAGE_ENDPOINT")
key = os.getenv("LANGUAGE_KEY")
client = TextAnalyticsClient(endpoint=endpoint, credential=AzureKeyCredential(key))

documents = ["The Windows 11 update brings a brand new start menu and improved performance."]
response = client.extract_key_phrases(documents)
print(response[0].key_phrases)

Try It Now

REST API Reference

POST /text/analytics/v3.1/keyPhrases

{
  "documents": [
    {
      "id": "1",
      "language": "en",
      "text": "Your document text here."
    }
  ]
}

Response:

{
  "documents": [
    {
      "id": "1",
      "keyPhrases": ["document text"]
    }
  ],
  "errors": [],
  "modelVersion": "latest"
}

Related Topics