Natural Language Processing – NLP for short – is the part of computer science that focuses on the interpretation of human language. Note the ‘understanding’ part: It’s not focused only on transcribing what you may say with your speech. NLP is about processing and understanding large amounts of natural language data, and to eventually generate natural language as well. This NLP training will be useful in explaining this new concept through NLP examples.
This article is divided into two parts. The first chapter covers the current usage and structure of Natural Language Processing engines today. This chapter is useful if you are considering to use NLP for a commercial or personal project today. The second chapter is about current NLP implementations that you can use every day. If you are more interested in the history of Natural Language Processing, check out the Wikipedia page.
What is Natural Language Processing or NLP
NLP is the set of techniques that allow computers to extract actionable, structured meaning from unstructured, natural human language. Extracting the meaning of an unstructured phrase, paragraph, sentence (or of a book, website, blog post, etc) is a very complex and potentially intensive task for a computer. The meaning may differ depending on a number of factors, such as words used, context, domain, and more. Take this phrase as an example:
Where would you like to go next?
If you were to read this message on your phone, its precise meaning will depend on the rest of the conversation with this person, the context of such conversation, and the overall situation where the interaction takes place. This interpretation is very fast and easy for a human but is actually really challenging for a computer.
NLP can be used to analyze text in various languages. A Natural Language Processing engine is usually language-specific since each language has a peculiar structure of the phrase.
Natural Language Processing today (NLP examples)
Natural Language Processing today can be exemplified by NLP examples. Take the following phrase:
I want to go to San Francisco tomorrow morning
The phrase above, for a computer, is just unstructured data for a computer. The processing engine is able to process this string and output a set of structured information that can be used by ‘normal’ computer code. For this example, I used Wit.ai to analyze the string. This is what I got:
A couple of things to unpack here. The engine identified:
- “San Francisco”: This is an entity of type location. You can imagine that in your code you will get something like $location = “San Francisco”
- “tomorrow”: This is an entity of type datetime. Note that the engine also translated it to a complete date time string that matches with tomorrow – in this case, 3/29/2018
- “I want to go”: This is an intent. It expresses what the user is actually trying to get out of the conversation. In this case, the user has an intent of type “travel”
Now, some considerations. You can imagine that if the user would have said ‘I would like to go’ or ‘I really want to go’, the engine should have picked them up as ‘intent travel’ as well. This is true if the engine works properly. In order to achieve the result above, I had to train an instance on the intent ‘travel’ myself, giving it a number of examples for the engine to learn. The number of examples does not have to be extra high – something like 30 or 40 examples are usually enough.
Also, note that the engine picked up by itself both the location and the datetime. The location is correct. The datetime is actually slightly incorrect as it picked up ‘tomorrow’ without ‘morning’. So in my code, I would not have any way of leveraging on the hour that the user expressed.
Everyday products that leverage on Natural Language Processing (NLP examples)
There are a number of products that you can use every day that leverage on any sort of Natural Language Processing. The most used apps are probably Alexa skills. In this case, the intent is captured as audio, transcribed with the use of text-to-speech technology, and the text is then handed over to your application for NLP. If you want to try a kind of advanced NLP, I suggest you use the eBay chatbot on Google home. You can summon it by saying “Ok Google, let me talk with eBay”.
Another example is Facebook Messenger bots. In this case, you can leverage the built-in NLP engine provided by Facebook. There are lots of funny chatbot examples that you can try without having to install anything else but Facebook Messenger.