Key phrase extraction with Azure Cognitive Services
Tags: azureapril, azure, ai, tutorial
Published: 2019-04-18 17:11:25

---
title: Key phrase extraction with Azure Cognitive Services
published: true 
description: How to extract key phrases from text using artificial intelligence
tags: azureapril, azure, ai, tutorial
series: Azure April
cover_image: https://thepracticaldev.s3.amazonaws.com/i/pblyvmtj4y8bdqisyzey.jpeg
---

*We've selected our favorite tips and tricks created by [Michael Crump](https://twitter.com/mbcrump) and are delivering fresh technical content on Azure all April! Miss a day (or more)? [Catch up with the series](https://dev.to/t/azureapril).*

**Don't have Azure?** [Grab a free subscription](https://azure.microsoft.com/en-us/free?&WT.mc_id=azureapril_devto-blog-cxa). 

I recently took a look at Text Analysis that was introduced with Cognitive Services and is now inside the Azure portal. If you open the Azure portal and look for **AI and Machine Learning** then you'll see the following:

![](https://thepracticaldev.s3.amazonaws.com/i/2uy9p3jym81zcw66z1uu.png)

Let's give **Text Analysis** a spin. Open the blade and fill out the following info. Be sure to select the **Free** tier (F0) as shown below:

![](https://thepracticaldev.s3.amazonaws.com/i/t3wp0j1cl7u7c0tpdutd.png)

Select **Keys** and copy the value of Key 1. 

![](https://thepracticaldev.s3.amazonaws.com/i/8utpjct0xwq1ore8mjrz.png)

We'll use [Postman](https://www.getpostman.com/) to test. Go ahead and download it if you haven't already and once complete you'll use one of the following endpoints depending on what you want to use. 

```text
https://westus.api.cognitive.microsoft.com/text/analytics/v2.0/sentiment
https://westus.api.cognitive.microsoft.com/text/analytics/v2.0/keyPhrases
https://westus.api.cognitive.microsoft.com/text/analytics/v2.0/languages
```

We'll use the  **keyPhrases** endpoint for learning purposes. 

**What are Key Phrases?** They automatically extract key phrases to quickly identify the main points. 

Copy the `https://westus.api.cognitive.microsoft.com/text/analytics/v2.0/keyPhrases` url into Postman and set the following three header properties:

* Ocp-Apim-Subscription-Key = should be your Key 1 (from our discussion earlier). 
* Content-Type = Set it to application/json.
* Accept = Set it to application/json.

Your screen should look like the following: 

![](https://thepracticaldev.s3.amazonaws.com/i/k2on4fwbn2dhp3uihoin.png)

Now switch over to **Body**, then **Raw** and post the following JSON (from some of my recent tweets):

```json
{
  "documents": [
    {
      "language": "en",
      "id": "1",
      "text": "Top 10 .NET Development Tweets that Broke the Web in 2017 - http://mcrump.me/2ot58Co  #dotnet"
    },
    {
      "language": "en",
      "id": "2",
      "text": "Setting up a managed container cluster with AKS and Kubernetes in the #Azure Cloud running .NET Core in minutes - http://mcrump.me/2op9mek  #dotnet"
    }
  ]
}

```

<img :src="$withBase('/files/aicog5.png')">

Now press **Send** and it will return key phrases from my tweets.

```json
{
  "documents": [
    {
      "keyPhrases": ["Web", ".NET Development Tweets", "dotnet"],
      "id": "1"
    },
    {
      "keyPhrases": [
        "Kubernetes",
        "Azure Cloud",
        "minutes -",
        "AKS",
        ".NET Core"
      ],
      "id": "2"
    }
  ],
  "errors": []
}
```

Want more Cognitive Services? Check out our [quickstarts and tutorials](https://azure.microsoft.com/en-us/try/cognitive-services/?WT.mc_id=azureapril_devto-blog-cxa)!

---

We'll be posting articles every day in April, so stay tuned or jump ahead and check out more tips and tricks [now](http://azuredev.tips).