Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Table of contents
1.
Introduction
2.
Background
3.
Phases In Natural Language Understanding
3.1.
Lexical Analysis 
3.2.
Syntactic Analysis
3.3.
Semantic Analysis
3.4.
Discourse Integration
3.5.
Pragmatic Analysis
4.
Understanding Pragmatics
5.
Importance of Pragmatics in NLP
6.
Aspects Of Pragmatics
6.1.
Deixis
6.2.
Implicature
6.2.1.
Conversational Implicature
6.2.2.
Conventional implicature
6.3.
Presupposition
6.4.
Speech Act
6.5.
Conversational Structure
7.
Frequently Asked Questions
7.1.
What is Pragmatic Ambiguity in NLP?
7.2.
How does Pragmatics differ from Semantics?
7.3.
What is the main advantage of Pragmatics?
7.4.
What are the different phases of NLP?
7.5.
What are the main aspects of Pragmatics?
8.
Conclusion
Last Updated: Mar 27, 2024
Easy

Pragmatics in NLP

Author Sinki Kumari
0 upvote
Master Python: Predicting weather forecasts
Speaker
Ashwin Goyal
Product Manager @

Introduction

Hello, ninjas! Let us dwell in the world of Natural Language Processing. Let’s understand an essential concept of Pragmatics in NLP. It tells us how context changes the actual meaning of a sentence. 

Pragmatics in NLP

Background

Let’s understand why we need pragmatics analysis concisely.

Language plays a vital role in our day-to-day life. It is a medium through which humans convey our thoughts, share our knowledge, or simply gossip. We group words to form meaningful sentences. We speak or write these sentences for the conversation to happen. Therefore there can be two ways to process it.

Processing the spoken form of language is much more challenging than the written form. NLP is the ability of a computer program to understand human language as it is. NLP comprises understanding, generating, and translating languages.

Now let’s understand how a computer understands human language.

Get the tech career you deserve, faster!
Connect with our expert counsellors to understand how to hack your way to success
User rating 4.7/5
1:1 doubt support
95% placement record
Akash Pal
Senior Software Engineer
326% Hike After Job Bootcamp
Himanshu Gusain
Programmer Analyst
32 LPA After Job Bootcamp
After Job
Bootcamp

Phases In Natural Language Understanding

The process of Natural Language understanding comprises five analytical phases. These Phases are:

Phases in NLU

The order is followed most of the time. Although there are cases where a different order is followed. Let us understand these phases in short.

Lexical Analysis 

In this phase, the lexical analyzer divides the incoming text into words, phrases, and paragraphs. It identifies the structure of words in sentences.

Syntactic Analysis

In this phase, the syntax analyzer will analyze the input text for grammatical problems. It organizes words such that there is a relationship among them. It can reject any incorrect sentence in the input text.

Semantic Analysis

This phase determines if the text has any meaning and attempts to discern its true meaning. Phrases like ‘dry water’ will be rejected by the semantic analyzer.

Discourse Integration

This phase analyzes how the immediately preceding sentence can influence the meaning of the next sentence. It explores the meaning in a bigger context, such as a paragraph or document level.

Pragmatic Analysis

This phase checks the real-world knowledge or context to derive the real meaning of the sentence.

The last step in this process is Pragmatic Analysis, our discussion topic.

The reason for giving you the background and steps in NLP was to set up the context for properly understanding pragmatics.

Understanding Pragmatics

Pragmatics in NLP is the study of contextual meaning. It examines cases where a person’s statement has one literal and another more profound meaning. It tells us how different contexts can change the meaning of a sentence. It is a subfield of linguistics that deals with interpreting utterances in communication. Pragmatics considers the intentions of the speaker and writer. Additional information is also considered to form the context.

There are many aspects of language that require knowledge derived from pragmatic analysis. It helps us understand whether the sentence “Give me a glass of water” is an order or a request. We cannot say this unless we have some context. 

Thus pragmatics in NLP helps the computer to understand the real meaning of the sentences in certain situations. Pragmatics is also concerned with the roles the speaker and the listener play in creating sense.

Example of Pragmatics

In the above image, the sentence “What time do you call this?!” does not mean “the teacher is asking her for the time”. This is the semantic meaning of the sentence. Here it is referred to as  “Why are you so late?” which is the pragmatic meaning of the sentence.

Importance of Pragmatics in NLP

The concept of pragmatics holds excellent importance for Natural Language Processing(NLP). It makes machines understand spoken and written language better. Pragmatics in NLP analyses the context and helps machines understand how it changes the meaning of utterances. NLP systems have been facing problems in their regard for a long time.

Through a few examples, let’s try to understand what would happen if pragmatics didn’t exist.

Example 1

‘Can you pull the car over?’

  • Actual MeaningAre you capable of pulling(literally pulling) the car
     
  • Pragmatic MeaningThis means ‘Can you stop the car’ .
     

Example 2

“Wow, that’s just what I needed.”

  • Actual Meaning: This may mean that someone was looking for something, and they found it. The sentence gives a positive sentiment here.
     
  • Pragmatic MeaningThis could express sarcasm and negative sentiment in a specific situation.


Example 3

Look at the situation/context to understand the actual meaning of the sentence spoken.

If you were told to “crack the window” and the room was a little stuffy. The speaker had just said before that they were feeling hot. We would know that the speaker wants you to “open the window” and not literally crack it.

Hence we can understand that it is essential for the computer to understand such sentences. It will be a better experience for NLP. It is necessary because it can help the machine grasp ambiguities. This allows the machine to interpret the correct meaning and structure of the sentence.

Aspects Of Pragmatics

There are following 5 Aspects Of Pragmatics:

Deixis

Deixis refers to words and phrases that show time, place, or situation when someone is talking. It refers to words or phrases such as “me,” “here,” etc., which are difficult to understand without additional information.

Example

1) Meet me here.

2) I wish you’d been here yesterday.

Implicature

Implicature means that more information is communicated than being said.

There are two types, namely,

Conversational Implicature

Conversational implicature is also known as Implication. It happens when the speaker says something that requires interpretation. It is an indirect way of saying something. It relies upon the cooperative principle.

Example

Person A: I am out of gas.

Person B: The gas station is around the corner.

Here it is implied that the gas station is near and open so that person A can go and fill in the gas.

Conventional implicature

Conventional implicature is directly attached to the literal meaning of the words. It does not rely on the cooperative principle.

Example: Abhishek is rich but sad.

Presupposition

A presupposition is when the speaker assumes something as a case before making an utterance.

Example: Jane no longer writes fiction.

Here it is assumed that Jane once wrote fiction.

Speech Act

A Speech Act is when the sentence conveys an action rather than saying something.

Example: I smashed a potato.

Here the action of smashing a potato is depicted.

Conversational Structure

Conversational structure refers to the underlying framework/Structure that tells the flow of a conversation. It follows rules, principles, and conventions in a meaningful dialogue.

Frequently Asked Questions

What is Pragmatic Ambiguity in NLP?

Pragmatic ambiguity refers to the fact that the same sentence can have different meanings in different situations. Pragmatic ambiguity can result in multiple interpretations of the same sentence.

How does Pragmatics differ from Semantics?

Pragmatics in NLP understands the language’s meaning but keeps the context in mind, whereas semantics only considers the actual meaning of the words in the sentence.

What is the main advantage of Pragmatics?

It enables the computer to understand the sentences’ real-world meaning. It considers the context, sarcasm, etc.

What are the different phases of NLP?

The phases of NLP are Lexical analysis, Syntactic analysis, Semantic analysis, Discourse integration, and Pragmatic analysis.

What are the main aspects of Pragmatics?

The main aspects of Pragmatics are Deixis, Implicature, Presupposition, Speech Act, and Conversational structure.

Conclusion

Pragmatics in NLP is the study of a sentence’s contextual meaning. Contextual meaning depends upon the situation, speaker, listener, tone of conversation, etc. The computer needs to have an understanding of pragmatics to comprehend the natural language of humans. There are five different Aspects of Pragmatics. They help in understanding the various implications of sentences. Pragmatics in NLP will help in two components of NLP, Natural Language Understanding (NLU) and Natural Language Generation(NLG).

Language is a framework that follows different principles. The main focus is to erase any uncertainty from the language to make communication much more effective.

To understand more about Natural Language Processing, click here.

To Check out some of the interview questions, click here.

To learn more about DSA, competitive coding, and many more knowledgeable topics, please look into the guided paths on Coding Ninjas Studio. Also, you can enroll in our courses and check out the mock test and problems available. Please check out our interview experiences and interview bundle for placement preparations.

Happy Coding!

Previous article
Conditional Random Fields
Next article
Conditional Random Fields
Live masterclass