Azure Tips and Tricks Part 70 - Key Phrase Extraction with Cognitive Service and Azure

2 minute read

Intro

Most folks aren’t aware of how powerful the Azure platform really is. As I’ve been presenting topics on Azure, I’ve had many people say, “How did you do that?” So I’ll be documenting my tips and tricks for Azure in these posts.

The Complete List of Azure Tips and Tricks

Available Now!

Key Phrase Extraction with Cognitive Service and Azure

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 Cognitive Services then you’ll see the following:

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:

Select Keys and copy the value of Key 1.

We’ll use Postman 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.

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:

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

{
        "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"
            }
        ]
}

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

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

As you can see it was very easy to get up and started. There obviously is a couple of SDKs that you can play with, but for now a quick test is all we need.

Want more Azure Tips and Tricks?

If you’d like to learn more Azure Tips and Tricks, then follow me on twitter or stay tuned to this blog! I’d also love to hear your tips and tricks for working in Azure, just leave a comment below.

Leave a Comment