How to Part-Of-Speech Tag a Text String and Filter the Verbs in C# .NET Framework with NLP

Part-of-speech (POS) tagging is an important step in many operations in Natural Language Processing (NLP), but it is quite a difficult one to set up. Rather than sink into the quagmire of tedium, let us dive straight into a simple solution that will get us the results we need in no time flat!

First we are going to download our package using NuGet:

Install-Package Cloudmersive.APIClient.NET.NLP -Version 4.0.9

Now we go ahead and give our function a call like this:

using System;using System.Diagnostics;using Cloudmersive.APIClient.NET.NLP.Api;using Cloudmersive.APIClient.NET.NLP.Client;using Cloudmersive.APIClient.NET.NLP.Model;namespace Example{public class PosTaggerTagVerbsExample{public void main(){// Configure API key authorization: ApikeyConfiguration.Default.AddApiKey("Apikey", "YOUR_API_KEY");// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed// Configuration.Default.AddApiKeyPrefix("Apikey", "Bearer");var apiInstance = new PosTaggerApi();var request = new PosRequest(); // PosRequest | Input stringtry{// Part-of-speech tag a string, filter to verbsPosResponse result = apiInstance.PosTaggerTagVerbs(request);Debug.WriteLine(result);}catch (Exception e){Debug.Print("Exception when calling PosTaggerApi.PosTaggerTagVerbs: " + e.Message );}}}}

And there you have it, all done!

Image for post

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store