Cloudmersive

Jul 15, 2020

1 min read

How to Part-Of-Speech POS Tag a String in C# .NET Framework

POS tagging is a necessary part of performing many language analysis routines, but it is quite a complex problem to get set up in C#. To help combat this difficulty, we will be showing you an ultra-fast shortcut. This will involve using an API, which will cut down our initial time investment significantly.

First we go ahead and download the package that we need.

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

Now go ahead and call the following function:

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 PosTaggerStringPostExample{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 PosTaggerStringApi();var input = input_example;  // string | Input stringtry{// Part-of-speech tag a stringstring result = apiInstance.PosTaggerStringPost(input);Debug.WriteLine(result);}catch (Exception e){Debug.Print("Exception when calling PosTaggerStringApi.PosTaggerStringPost: " + e.Message );}}}}

Done! Super simple.