Key phrase extraction with AI Builder

Key phrase extraction

The key phrase extraction model identifies the main points in a text document. For example, given input text “The food was delicious and there were wonderful staff”, the service returns the main talking points: “food” and “wonderful staff”. This model can extract a list of key phrases from unstructured text documents.

As this is a pre-built model, there is not training or configuration to tend to. We can jump right in to consuming it.

We will build a Flow to consume the text we provide, then extract out our key phrases and send an email notification with an HTML formatted list of those key phrases.

You can use this output in many ways using the Common Data Service, but for our limited lab purposes we will stick to the simple email scenario.

 

Exercise 1

  1. Navigate to https://make.powerapps.com/ and make sure you have the aibignite environment selected.

  1. Expand AI Builder and select Build.

  1. Select Solutions.

  1. Select the Default
    Solution. In a real project you wouldn’t add items directly to the default solution. However, in the interest of time for our lab, we will use that for our purposes.

  1. While viewing the Default Solution, click + New and select Flow.

  1. Search for trigger and select Manually trigger a flow.

  1. You will now add two inputs. The first one for My Text and the second for My Language. This will be how we add our text and language to be analyzed. Text is limited to a maximum of 5,120 characters and the following languages: Chinese. English, French, German, Italian, Japanese, Korean, Portuguese, and Spanish. Click Add an input.

  1. Select Text.

  1. Enter My Text for title and click Add an input again.

  1. Select Text again.
  2. Enter My Language for title and click + New Step.

  1. Search for predict and select Predict Common Data Service (current environment).

  1. Select KeyPhraseExtraction model, type {“text”:” in the Request Payload field and select My Text from the Dynamic Content pane.

  1. Type “, “language”:” and select My Language from the Dynamic Content pane.

  1. Add “} and click + New Step.

  1. Search for parsed and select Parse JSON.

  1. Click on the Content field and select Response Payload from the Dynamic Content pane.

  1. Copy the following JSON and paste in the Schema field.

    {

“type”: “object”,

“properties”: {

“predictionOutput”: {

“type”: “object”,

“properties”: {

“results”: {

“type”: “array”,

“items”: {

“type”: “object”,

“properties”: {

“phrase”: {

“type”: “string”

}

},

“required”: [

“phrase”

]

}

}

}

},

“operationStatus”: {

“type”: “string”

},

“error”: {}

}

}

  1. Save your flow.

 

Exercise 2

That’s all we need to build to use the model. Let’s now take the information produced and send it in an email notification.

  1. Click + New Step.

  1. Search for create and select Create HTML table.

  1. Click on the From field, select results from the Dynamic Content pane, and click Show Advanced Options.

  1. Select Automatic and click + New Step.

  1. Search for send an email and select Send an Email (V2).

  1. Enter the email of your lab user for To.
  2. Enter Key phrase for Subject.
  3. Click on the Body field and select My Text from Dynamic Content pane.

  1. Hit the [ENTER KEY] twice and select My Language from the Dynamic Content pane.
  2. Hit the [ENTER KEY] twice and select Output from the Dynamic Content pane.

  1. Click Save.
  2. Click Test.

  1. Select I’ll perform the trigger action and click Save & Test.

  1. Click Continue.

  1. Enter the following text and click Run flow.
    Text: More than 2 hours after my arrival with a pain scale of 10, i was never examined. i explained to the e.r. nurse and was told all I have to do is get up and leave if i can’t wait. so i did. very unprofessional and inhumane.
    Language: en

  1. Click Done.
  2. Confirm the successful flow run.

  1. Navigate to https://outlook.office365.com
  2. Go check your email for the results. You should see our email subject (1); the input (2) and the phrases that were extracted and formatted to our HTML table (3).

  1. Try more phrases. Make your own or try our examples.
    1. What can I say, I got into the hospital super sick and after a great care experience I am now fully recovered. I want to highlight the great human care provided by the doctors and nurses, they made me feel not like any other patient but like a unique human being.
    2. More than 2 hours after my arrival with a pain scale of 10, i was never examined. i explained to the e.r. nurse and was told all i have to do is get up and leave if i can’t wait. so i did. very unprofessional and inhumane.
    3. I went to this hospital today because I was suffering from a fever. I arrived at 9:30 am and I left 9:30pm. During that time, they gave me medication that you’re supposed to take with food. In about 20 minutes, my stomach hurts. I asked three people for food, one being my doctor, to no avail.
    4. Excellent care from Maternity staff – including consultant (and team), surgical staff who delivered both our sons via c-section and all nursing/supportstaff who helped with stay in hospital

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s