Skip to main content

Extracting Key Phrases from Text Using the .NET SDK

Hands-On Lab

 

Photo of

Training Architect

Length

01:00:00

Difficulty

Intermediate

In this hands-on lab, we use Visual Studio and C# to access a pre-created Azure Cognitive Service resource and have it perform key phrase extraction. All the code is already written. We simply need to configure the service endpoint and key, then run the code to perform the analysis.

What are Hands-On Labs?

Hands-On Labs are scenario-based learning environments where learners can practice without consequences. Don't compromise a system or waste money on expensive downloads. Practice real-world skills without the real-world risk, no assembly required.

Extracting Key Phrases within Text Using the .NET SDK

Introduction

In this hands-on lab, we use Visual Studio and C# to access a pre-created Azure Cognitive Service resource and have it identify named entities in a piece of text. All the code is already written. We simply need to configure the service endpoint and key, then run the code to perform the analysis.

Solution

Log in to the Azure Portal using the credentials provided on the lab instructions page.

Once you're logged in, navigate to All resources. Once there, open the listed virtual machine and Cognitive Service resource in new browser tabs.

Use RDP to Connect to the Visual Studio Virtual Machine

Use the Remote Desktop client (available from Microsoft for Windows clients natively and Mac clients here).

  1. On the virtual machine page in the portal, click Connect.
  2. Click Download RDP File.
  3. Open the file with the RDP client.
  4. Edit the desktop to:
    • Make sure you are not in an admin session.
    • Make sure the remote session does not launch in full-screen mode.
    • Set the resolution to something that will give us room to maneuver in both the remote and local desktops (e.g., 1024 x 768).
  5. Log in with the provided credentials

Note: If you're on a Mac, instead of downloading the RDP file, you will instead need to copy the public IP address of the virtual machine in the Azure Portal and use that to access the virtual machine via your RDP client.

Open and Configure Visual Studio

  1. Open Visual Studio using either the Start menu or the desktop icon.
  2. Click Sign in.
  3. Log in using the credentials you used to log in to the Azure Portal, and click Sign in.
  4. Select the defaults for all other Visual Studio options.
  5. Click Start Visual Studio. Be patient as this takes a few minutes to complete.
  6. Click Check for an updated license.
  7. Click Close.

Open the Visual Studio Solution

  1. Click Open a project or solution.
  2. Click This PC in the left-hand menu.
  3. Click Window (C:).
  4. Open the code folder.
  5. Open the LinuxAcademy.Azure.AI.KeyPhraseExtraction folder.
  6. Double-click the LinuxAcademy.Azure.AI.KeyPhraseExtraction file to open it.
  7. Open Program.cs.

Configure the Endpoint and Key, and Run the App

  1. On the Cognitive Service resource page in the Azure Portal, copy the key.
  2. Paste it into the string key line (line 16) of the Visual Studio code, before the semicolon, and surround it with quotation marks.
  3. On the Cognitive Service resource page in the Azure Portal, copy the endpoint.
  4. Paste it into the string endpoint line (line 15) of the Visual Studio code, before the semicolon, and surround it with quotation marks.
  5. Run the solution and examine the results.

Conclusion

Congratulations on successfully completing this hands-on lab!