Semantic Similarity Methods for Semantic Parsing

Let's learn how we can calculate the semantic similarity between different texts.

Natural language allows us to express the same concept in different ways and with different words. Every language has synonyms and semantically related words.

As an NLP developer, while developing a semantic parser for a chatbot application, text classification, or any other semantic application, you should keep in mind that users use a fairly wide set of phrases and expressions for each intent. In fact, if you're building a chatbot by using a platform such as RASA or on a platform such as Dialogflow, we're asked to provide as many utterance examples as we can provide for each intent. Then, these utterances are used to train the intent classifier behind the scenes.

There are usually two ways to recognize semantic similarity, either with a synonyms dictionary or with word vector-based semantic similarity methods. We will discuss both approaches. Let's start with how to use a synonyms dictionary to detect semantic similarity.

Using synonyms lists for semantic similarity

We already went through our dataset and saw that different verbs are used to express the same actions. For instance, landing, arriving, and flying to verbs carry the same meaning, whereas leaving, departing, and flying from verbs form another semantic group.

We already saw that in most cases, the transitive verbs and direct objects express the intent. An easy way to determine whether two utterances represent the same intent is to check whether the verbs and the direct objects are synonyms.

Let's take an example and compare two example utterances from the dataset. First, we prepare a small synonyms dictionary. We include only the base forms of the verbs and nouns. While doing the comparison, we also use the base form of the words:

Get hands-on with 1200+ tech skills courses.