How to Separate all Words in a String in C# .NET Framework with NLP

Separating a string out into individual words isn’t always as easy as it might seem. There are a lot of rare cases and punctuation to account for. Instead of dealing with all of that, I’m here today to bring you a super easy solution that can have you ready to go in just a few minutes, using the power of NLP!

First we will need our package:

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

Now we can call this function right here:

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 WordsGetWordsStringExample{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 WordsApi();var input = input_example;  // string | Input stringtry{// Get words from stringstring result = apiInstance.WordsGetWordsString(input);Debug.WriteLine(result);}catch (Exception e){Debug.Print("Exception when calling WordsApi.WordsGetWordsString: " + e.Message );}}}}

Whew! Already done. What a breeze.

Written by

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