Natural Language Processing (NLP) Guide – What Is NLP & How Does it Work?

Natural Language Processing

Natural Language Processing (NLP) allows machines to interpret human language. It’s at the core of many tools that we use every day – from translation software, chatbots, spam filters, and search engines, to grammar checking software, voice assistants, and social media monitoring tools.

This guide covers the basics of natural language processing, delves into natural language processing applications and techniques, and explains how easy it is to perform natural language processing using NLP tools like MonkeyLearn.

  1. What Is Natural Language Processing (NLP)?
  2. How Does Natural Language Processing Work?
  3. Natural Language Processing Examples
  4. Natural Language Processing in Python
  5. Natural Language Processing Tutorial

Let’s dive right into it!

What Is Natural Language Processing (NLP)?

What is NLP?

Natural Language Processing (NLP) is a field of Artificial Intelligence (AI) that quantifies human language to make it intelligible to machines. Natural language processing combines the power of linguistics and computer science to study the rules and structure of language, and create intelligent systems capable of understanding, analyzing, and extracting meaning from text and speech.

Natural language understanding (NLU) is used to understand the structure and meaning of human language by analyzing different aspects like syntax, semantics, pragmatics, and morphology. Then, computer science transforms this linguistic knowledge into rule-based or machine learning algorithms that can solve specific problems and perform desired tasks.

Take Gmail, for example. Emails are automatically categorized as Promotions, Social, Primary, or Spam, thanks to an NLP task called keyword extraction. By extracting words in subject lines and associating words with tags, machines automatically learn which category to assign emails.

Top advantages of natural language processing include:

  • Large-scale analysis. Natural Language Processing can help machines automatically understand and analyze huge amounts of unstructured data, such as customer support tickets, customer feedback, conversations on social media, and beyond.
  • Automated processes in real-time. Natural language processing tools can help machines learn to sort and route information without human help – quickly, effectively, and around the clock.
  • Tailored to your industry. Natural language processing algorithms can be tailored to your needs and criteria, which is essential in industries that use complex, industry-specific language

How Does Natural Language Processing Work?

How Does NLP Work?

Natural language processing uses algorithms (or sets of rules) that are often based on machine learning algorithms. Machine learning algorithms learn to understand human language by observing previous text samples

These systems work by transforming text into something a machine can understand (vectors), a process known as feature extractor or text vectorization. Once the texts have been transformed into vectors, they are fed to a machine learning algorithm, together with their expected output (tags), to train machines to make associations between a particular input and its corresponding output.

Machines then use statistical analysis methods to build their own ‘knowledge bank’ and discern which features best represent the texts, before making predictions for unseen data:

Machine learning process, from training to prediction

Ultimately, the more data machine learning algorithms are fed, the more accurate the systems will be.

Let’s use sentiment analysis as an example. You can build a machine learning model to automatically classify opinions as positive, negative, or neutral. But first, you need to train your classifier by manually tagging text examples, until it’s ready to make its own predictions on unseen data.

The biggest advantage of machine learning models is their ability to learn on their own, with no need to define manual rules. All you’ll need is a set of relevant training data, with several examples for each of the tags you’d like to analyze.

Natural Language Processing (NLP) Tasks & Techniques

Many natural language processing tasks involve syntactic and semantic analysis, used to break down human language into machine-readable chunks.

Syntactic analysis ― also known as parsing or syntax analysis ― identifies the syntactic structure of a text and the dependency relationships between words, represented on a diagram called a parse tree.

Semantic analysis focuses on identifying the meaning of language. However, since language is polysemic and ambiguous, semantics is considered one of the most challenging areas in NLP.

Semantic tasks analyze the structure of sentences, word interactions, and related concepts, in an attempt to discover the meaning of words, as well as understand the topic of a text.

Below, we’ve listed some of the main sub-tasks of both semantic and syntactic analysis:


This is an essential task in natural language processing. Used to break up a string of words into semantically useful units called tokens, it works by defining boundaries, that is, a criterion of where a token begins or ends.

You can use sentence tokenization to split sentences within a text, or word tokenization to split words within a sentence. Generally, word tokens can be separated by blank spaces, and sentence tokens by stops. However, you can perform high-level tokenization for more complex structures, like words that often go together, otherwise known as collocations (for example, New York).

Here’s an example of how word tokenization simplifies text:

Customer service couldn’t be better! = [“customer service” “could” “not” “be” “better”].

Part-of-speech tagging

Part-of-speech tagging (abbreviated as PoS tagging) involves adding a part of speech category to each token within a text. Some common PoS tags are verb, adjective, noun, pronoun, conjunction, preposition, intersection, among others. In this case, the example above would look like this:

“Customer service”: NOUN, “could”: VERB, “not”: ADVERB, be”: VERB, “better”: ADJECTIVE, “!”: PUNCTUATION

PoS tagging is useful for identifying relationships between words and, therefore, understand the meaning of sentences.

Dependency Parsing

Dependency grammar refers to the way the words in a sentence are connected. A dependency parser, therefore, analyzes how ‘head words’ are related and modified by other words too understand the syntactic structure of a sentence:

Dependency Parsing

Constituency Parsing

Constituency Parsing aims to visualize the entire syntactic structure of a sentence by identifying phrase structure grammar. It consists of using abstract terminal and non-terminal nodes associated to words, as shown in this example:

Constituency Parsing

You can try different parsing algorithms and strategies depending on the nature of the text you intend to analyze, and the level of complexity you’d like to achieve.

Lemmatization & Stemming

When we speak or write, we tend to use inflected forms of a word (words in their different grammatical forms). To make these words easier for computers to understand, NLP uses lemmatization and stemming to transform them back to their root form.

The word as it appears in the dictionary – its root form – is called a lemma. For example, the terms ‘are, is, am, were, and been,’ are grouped under the lemma ‘be.’ So, if we apply this lemmatization to “African elephants have four nails on their front feet,” the result will look something like this:

African elephants have four nails on their front feet = [“African,” “elephant,” “have,” “4”, “nail,” “on,” “their,” “foot”]

This example is useful to see how the lemmatization changes the sentence using its base form (e.g., the word feet was changed to foot).

When we refer to stemming, the root form of a word is called a stem. Stemming ‘trims’ words, so word stems may not always be semantically correct.

For example, stemming the words “consult,” “consultant,” “consulting,” and “consultants” would result in the root form “consult.”

While lemmatization is dictionary-based and chooses the appropriate lemma based on context, stemming operates on single words without considering the context. For example, in the sentence:

“This is better”

The word “better” is transformed into the word “good” by a lemmatizer but is unchanged by stemming. Even though stemmers can lead to less-accurate results, they are easier to build and perform faster than lemmatizers. However, the latter is better if you're seeking more precise linguistic rules.

Stopword Removal

Removing stop words is an essential step in NLP text processing. It involves filtering out high-frequency words that add little or no semantic value to a sentence, for example, which, to, at, for, is, etc.

You can even customize lists of stopwords to include words that you want to ignore.

Let’s say you’d like to classify customer service tickets based on their topics. In this example: “Hello, I’m having trouble logging in with my new password”, it may be useful to remove stop words like “hello”, “I”, “am”, “with”, “my”, so you’re left with the words that help you understand the topic of the ticket: “trouble”, “logging in”, “new”, “password”.

Word Sense Disambiguation

Depending on their context, words can have different meanings. Take the word “book”, for example:

  • You should read this book; it’s a great novel!
  • You should book the flights as soon as possible.
  • You should close the books by the end of the year.
  • You should do everything by the book to avoid potential complications.

There are two main techniques that can be used for Word Sense Disambiguation (WSD): knowledge-based (or dictionary approach) and a supervised approach. The first one tries to infer meaning by observing the dictionary definitions of ambiguous terms within a text; while the latter is based on machine learning algorithms that learn from examples (training data).

Named Entity Recognition (NER)

This is one of the most popular tasks in semantic analysis and involves extracting entities from text. Entities can be names, places, organizations, email addresses, and beyond.

Relationship extraction takes NER one step further by finding relationships between two nouns. For example, in the phrase “Susan lives in Los Angeles,” a person (Susan) is related to a place (Los Angeles) by the semantic category “lives in.”

Text Classification

Text classification is the process of understanding the meaning of unstructured text and organizing into predefined categories (tags). One of the most popular text classification tasks is sentiment analysis, which aims to categorize unstructured data by sentiment. Try out this pre-trained online sentiment analyzer to see how it works.Other classification tasks include intent detection, topic modeling, and language detection.

Natural Language Processing (NLP) Examples

Use Cases & Applications

Thanks to NLP-powered systems, companies can automate tasks like ticket tagging, routing, and data entry, and gain fine-grained insights to make data-driven decisions.

Here are some examples of how NLP is used every day in business:

  • Monitor brand sentiment on social media
  • Sorting customer feedback
  • Automating processes in customer support
  • Chatbots for customer success
  • Automatic summarization
  • Machine translation
  • Natural language generation

Monitor Brand Sentiment on Social Media

Sentiment analysis is the automated process of classifying opinions in a text as positive, negative, or neutral. It’s often used to monitor sentiments on social media. You can track and analyze sentiment in comments about your overall brand, a product, particular feature, or maybe about a specific team.

Imagine you’ve just released a new product and want to detect your customers’ initial reactions. Maybe a customer tweeted discontent about your customer service. By tracking sentiment analysis, you can spot these negative comments right away and respond immediately.

Quickly Sorting Customer Feedback

Text classification is a core NLP task which consists of assigning predefined categories (tags) to a text, based on its content. It’s great for categorizing qualitative feedback, such as product reviews, social media conversations, and open-ended responses in online surveys.

Retently, a SaaS platform, used NLP tools to classify NPS responses and gain actionable insights in next to no time:

Feedback classification categories used by Retently: onboarding, product performance, UI, UX, features, ease of use, integrations, reporting, customer support, pricing

Retently discovered the topics mentioned most often by customers, and which ones they valued most.

Below, you can see that most of the responses referred to “Product Features,” followed by “Product UX” and “Customer Support” (the last two topics were mentioned mostly by Promoters).

Response Tags Analysis

Automating Processes in Customer Service

Other interesting applications of NLP revolve around customer service automation. This concept uses AI-based technology to eliminate or reduce routine manual tasks in customer support, saving agents valuable time, and making processes more efficient.

According to the Zendesk benchmark, a tech company receives +2600 support inquiries per month. Receiving large amounts of support tickets from different channels (email, social media, live chat, etc), means companies need to have a strategy in place to categorize each incoming ticket.

Text classification allows companies to automatically tag incoming customer support tickets according to their topic, language, sentiment, or urgency. Then, based on these tags, they can instantly route tickets to the most appropriate pool of agents.

Uber designed its own ticket routing workflow, which involves tagging tickets by Country, Language, and Type (this category includes the sub-tags Driver-Partner, Questions about Payments, Lost Items, etc), and following some prioritization rules, like sending requests from new customers (New Driver-Partners) to the top of the list.

Chatbots for Customer Success

A chatbot is a computer program that simulates human conversation. Chatbots use NLP to recognize the intent behind a sentence, identify relevant topics and keywords, verbs, and even emotions, and come up with the best response based on their interpretation of data.

As customers crave fast, personalized, and around-the-clock support experiences, chatbots have become the heroes of customer service strategies. Chatbots reduce customer waiting times by providing immediate responses and excel when handling routine queries (which often represent a high volume of customer support requests), allowing agents to focus on solving more complex issues. In fact, chatbots can solve up to 80% of routine customer support tickets.

Besides providing customer support, chatbots can be used to recommend products, offer discounts, and make reservations, among many other tasks. In order to do that, most chatbots follow a simple ‘if/then’ logic (they are programmed to identify intents and associate them with a certain action), or provide a selection of options to choose from.

Automatic Summarization

Automatic summarization consists of reducing a text and creating a concise new version that contains its most relevant information. It can be particularly useful to summarize large pieces of unstructured data, such as academic papers.

There are two different ways to use NLP for summarization:

  1. To extract the most important information within a text and use it to create a summary (extraction-based summarization)
  2. Apply deep learning techniques to paraphrase the text and produce sentences that are not present in the original source (abstraction-based summarization).

Automatic summarization can be particularly useful for data entry, where relevant information is extracted from, let’s say a product description, and automatically entered into a database.

Machine Translation

The possibility of translating text and speech to different languages has always been one of the main interests in the NLP field. From the first attempts to translate text from Russian to English in the 1950s to the state-of-the-art neural systems, machine translation (MT) has seen significant improvements but still presents challenges.

Google Translate, Microsoft Translator, and Facebook Translation App are a few of the leading platforms for generic machine translation. In August 2019, Facebook AI English-to-German machine translation model received first place in the contest held by the Conference of Machine Learning (WMT). The translations obtained by this model were defined by the organizers as “superhuman” and considered highly superior to the ones performed by human experts.

Another interesting development in machine translation has to do with customizable machine translation systems, which are adapted to a specific domain and trained to understand the terminology associated with a particular field, such as medicine, law, and finance. Lingua Custodia, for example, is a machine translation tool dedicated to translating technical financial documents.

Finally, one of the latest innovations in MT is adaptative machine translation, which consists of systems that can learn from corrections in real-time.

Natural Language Generation

Natural Language Generation (NLG) is a subfield of NLP designed to build computer systems or applications that can automatically produce all kinds of texts in natural language by using a semantic representation as input. Some of the applications of NLG are question answering and text summarization.

In 2019, artificial intelligence company Open AI released GPT-2, a text-generation system that represented a groundbreaking achievement in AI and has taken the NLG field to a whole new level. The system was trained with a massive dataset of 8 million web pages and it’s able to generate coherent and high-quality pieces of text (like news articles, stories, or poems), given minimum prompts.

The model performs better when provided with popular topics which have a high representation in the data (such as Brexit, for example), while it offers poorer results when prompted with highly niched or technical content. Still, it’s possibilities are only beginning to be explored.

Natural Language Processing in Python


Now that you’ve gained some insight into the basics of NLP and its current applications in business, you may be wondering how to put NLP into practice.

There are many open-source libraries designed to deal with Natural Language Processing. The good thing about these libraries is that they are free, flexible, allow you to build a complete and customized NLP solution, and are often written in Python (the best language for performing NLP tasks). However, building a whole infrastructure from scratch demands both programming skills and machine learning knowledge.

SaaS tools, on the other hand, are ready-to-use solutions that allow you to incorporate NLP into your apps in a very simple way, with very little setup. Connecting SaaS tools to your favorite apps through their APIs is super simple and only requires a few lines of code, and it’s an excellent alternative if you don’t want to invest time and resources learning about machine learning or NLP.

Here’s a list of the top NLP tools:

  • MonkeyLearn is a SaaS platform that lets you build customized natural language processing models to perform tasks like sentiment analysis and keyword extraction. Developers can connect text analysis models via the MonkeyLearn API in Python, while those with no programming skills can upload datasets via the smart interface or connect to everyday apps like Google Sheets, Excel, Zapier, Zendesk, and more.
  • Natural Language Toolkit (NLTK) is a suite of libraries for building Python programs that can deal with a wide variety of NLP tasks. It is the most popular Python library for NLP, has a very active community behind it, and is often used for educational purposes. There’s a handbook and tutorial for using NLTK, but learning how to use it might take some time.
  • SpaCy is a free open source library for advanced NLP in Python. It has been specifically designed to build NLP applications that can help you understand large volumes of text. That’s one of the differences with its main competitor, NLTK, which was created mostly for research and teaching purposes. SpaCy is fast, easy to use, and very well documented. Instead of presenting you with all the available options to solve an NLP problem, it focuses on the best algorithm you can use for that task. However, for the time being, it only supports the English language.
  • TextBlob is a Python library with a simple interface to perform a variety of NLP tasks. Built on the shoulders of NLTK and another library called Pattern, it is intuitive and user-friendly, which makes it ideal for beginners. Learn more about how to use TextBlob and its features.

Natural Language Processing Tutorial


SaaS solutions like MonkeyLearn offer ready-to-use NLP tools for text analysis.

You can also upload a CSV or Excel file to analyze a large batch of data, use one of the available integrations, or connect through the MonkeyLearn API.

Ready-to-use models are great for taking your first steps with sentiment analysis. However, if you need to analyze industry-specific data, you should build your own customized classifier. Custom sentiment models can detect words and expressions within your domain for more accurate predictions.

These are the steps you need to follow to create a customized sentiment analysis model with MonkeyLearn. Before you start, you’ll need to sign up to MonkeyLearn for free:

1. Choose a type of model. Go to the dashboard, click on Create Model and choose “Classifier”.

Choose a Model Type

2. Choose a type of classifier. In this case, “Sentiment Analysis”.

Kind of Classification

3. Upload training data. You can import data from a CSV or an Excel file, or connect with any of the third-party integrations offered by MonkeyLearn, such as Twitter, Gmail, Zendesk, and Front, among others. This data will be used to train your machine learning model.

Upload Data

4. Tag your data. It’s time to train your sentiment analysis classifier by manually tagging examples of data as positive, negative, or neutral. The model will learn based on your criteria, and the more examples you tag, the smarter your model will become. Notice that after tagging several examples, your classifier will start making its own predictions.

Tag Data

5. Test your sentiment analysis classifier. After training your model, go to the “Run” tab, enter your own text and see how your model performs. If you are not satisfied with the results, keep training your classifier y tagging more examples.

Test Model

6. Put your model to work! Use your sentiment classifier to analyze your data. There are three ways to do this:

  1. Upload a batch of data (like a CSV or an Excel file)
  2. Use one of the available integrations
  3. Connect to the MonkeyLearn API
Using a Keyword Extractor

With a keyword extractor, you can easily pull out the most important words and expressions from a text, whether it’s a set of product reviews or a bunch of NPS responses. You can use this pre-trained model for extracting keywords or build your own custom extractor with your data and criteria.

These are the steps for building a custom keyword extractor with MonkeyLearn:

1. Choose a type of model. Go to the dashboard, click on Create Model and choose “Extractor”.

2. Import your text data. You can upload a CSV or an Excel file, or import data from a third-party app like Twitter, Gmail, or Zendesk.

Upload Data

3. Specify the data you’ll use to train your keyword extractor. Select which columns you will use to train your model.

Specify Data

4. Define your tags. Create different categories (tags) for the type of data you’d like to obtain from your text. In this example, we’ll analyze a set of hotel reviews and extract keywords referring to “Aspects” (feature or topic of the review) and “Quality” (keywords that refer to the condition of a certain aspect).

Define Tags

5. Train your keyword extractor. You’ll need to manually tag examples by highlighting the keyword in the text and assigning the correct tag.

Tag Data

6. Test your model. Paste new text into the text box to see how your keyword extractor works.

Test Model

7. Put your model to work! Upload data in a batch, try one of our integrations, or connect to the MonkeyLearn API.

Final Words

Natural language processing is transforming the way we analyze and interact with language-based data by creating machines capable of making sense of text and speech and performing human tasks like translation, summarization, classification, and extraction.

Not long ago, the idea of computers capable of understanding human language seemed impossible. However, in a relatively short time ― and fueled by research and developments in linguistics, computer science, and machine learning ― NLP has turned into one of the most promising and fastest-growing fields within AI.

There are many NLP use cases in business, which involve structuring data to gain valuable insights and automate routine tasks.

As technology advances, NLP is becoming more accessible. Thanks to NLP-based software like MonkeyLearn, it’s getting easier for companies to create customized solutions that help them automate processes and better understand their customers.

Ready to get started? Request a demo and let us know how we can help you get started.

MonkeyLearn Inc. All rights reserved 2020