0% found this document useful (0 votes)
10 views51 pages

Understanding Natural Language Processing

Artificial intelligence for 5 the sem Bangalore univesity,lecturer notes

Uploaded by

ananthalakshmi
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views51 pages

Understanding Natural Language Processing

Artificial intelligence for 5 the sem Bangalore univesity,lecturer notes

Uploaded by

ananthalakshmi
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

Natural language

processing
NLP
Natural Language processing (NLP)
Natural language processing (NLP) is a field of computer
science and a subfield of artificial intelligence that aims to
make computers understand human language.

We use the English language to communication between an


intelligent system and NLP

Processing of NL plays an important role in various system


For Example:
A robot, it is used to perform as per your instruction the
input & output of an N.L.P System can be

❖Speech
❖Written text
Components of
NLP
Natural Language Processing (NLP) has several components,
including:
•Natural Language Understanding (NLU)
-Basically, the mapping to given input in Natural Language into
useful representation
. Analyzing different aspects of the language
•Natural Language Generation (NLG)
•We have to produce meaningful phrases and sentences. That is
in the form of NL internal representation & NLG Involves
• Text planning
• Sentences planning
NLU NLG
• NLU is the process of reading • NLG is the process of writing or
and interpreting language generating language.

• It produces constructing natural


• It produces non-linguistic language outputs from non-
outputs from natural language linguistic inputs.
inputs
Ambiguity (DOUBT)

NLP(Natural Language Processing) is hard


because language is ambiguous, one word,
one phrase, or one sentence can mean
different things depending on the context.

As humans we can understand the context, but


machines cannot so in NLP we have to find a
way to make machine understand the context
somehow.
Types of Ambiguities : -
1. Lexical Ambiguity -
When words have more than one meaning
e.g. - Bank (match in context of finance) or (match in
context of river)

2. Syntactic Ambiguity -
When sequence of words or a sentence has more
than one meaning.

e.g. - "One morning, I shot an elephant in my


3. Referential Ambiguity
When the subject is pointed more than once
in a sentence.

e.g. - The boy told his father the theft. He


was very upset.
Here who does "He" refer to ??
4. Anaphoric Ambiguity –
A phrase or word refers to something
previously mentioned, but there is more than
one possibility.

e.g. - Pooja invited Ria for a visit, but she told


her she had to go to work.

here "she" and "her" can be used for for Pooja


and Ria interchangeably, which give two different
meanings.
5. Pragmatic Ambiguity - when the statement is not
specific, and the context does not provide the
information needed to clarify the statement.
(Some Information is Missing)
e.g. - “The police are coming”

Does this mean they are coming for you/me (I hope


they better not ), they are coming down the road ?
NLP pipeline
There are the following steps to build an NLP pipeline
-
Step1: Sentence Segmentation

Sentence Segment is the first step for building the NLP pipeline. It
breaks the paragraph into separate sentences.

Example: Consider the following paragraph –

Independence Day is one of the important festivals for every


Indian citizen. It is celebrated on the 15th of August each year
ever since India got independence from the British rule. The day
celebrates independence in the true sense.
Sentence Segment produces the following result:

1."Independence Day is one of the important festivals


for every Indian citizen.“

2."It is celebrated on the 15th of August each year ever


since India got independence from the British rule.“

3."This day celebrates independence in the true sense."


Step2: Word Tokenization
Word Tokenizer is used to break the sentence into separate
words or tokens.

Example:
JavaTpoint offers Corporate Training, Summer Training,
Online Training, and Winter Training.

Word Tokenizer generates the following result:

"JavaTpoint", "offers", "Corporate", "Training", "Summer",


"Training", "Online", "Training", "and", "Winter", "Training", "."
Step3: Stemming
Stemming is used to normalize words into its base form or
root form.

For example, celebrates, celebrated and celebrating, all


these words are originated with a single root word
"celebrate."

The big problem with stemming is that sometimes it


produces the root word which may not have any meaning.

For Example, intelligence, intelligent, and intelligently, all


these words are originated with a single root word "intelligent."
In English, the word "intelligen" do not have any meaning.
Step 4: Lemmatization
Lemmatization is quite similar to the Stamming.

It is used to group different inflected forms of the


word, called Lemma.

The main difference between Stemming and


lemmatization is that it produces the root word, which
has a meaning.

For example: In lemmatization, the words


intelligence, intelligent, and intelligently has a root
word intelligent, which has a meaning.
Step 5: Identifying Stop Words

In English, there are a lot of words that appear


very frequently like "is", "and", "the", and "a".
NLP pipelines will flag these words as stop
words.

Stop words might be filtered out before doing


any statistical analysis.

Example: He is a good boy.


Step 6: Dependency Parsing

Dependency Parsing is used to find that how


all the words in the sentence are related to
each other.
Step 7: POS tags

POS stands for parts of speech, which includes Noun, verb, adverb,
and Adjective.

It indicates that how a word functions with its meaning as well as


grammatically within the sentences.

A word has one or more parts of speech based on the context in which it is
used.

Example: "Google" something on the Internet.

In the above example, Google is used as a verb, although it is a


proper noun.
Step 8: Named Entity Recognition (NER)

Named Entity Recognition (NER) is the process of


detecting the named entity such as person name,
movie name, organization name, or location.

Example: Steve Jobs introduced iPhone at the


Macworld Conference in San Francisco, California.
Step 9: Chunking
Chunking is used to collect the
individual piece of information
and grouping them into bigger
pieces of sentences.
Phases of NLP
There are the following five phases of NLP:
1. Lexical Analysis and Morphological

• The first phase of NLP is the Lexical Analysis.

• This phase scans the source code as a stream of


characters and converts it into meaningful lexemes.

• It divides the whole text into paragraphs, sentences,


and words.
2. Syntactic Analysis (Parsing)

Syntactic Analysis is used to check grammar, word


arrangements, and shows the relationship among the
words.

Example: Agra goes to the Poonam

In the real world, Agra goes to the Poonam, does not


make any sense, so this sentence is rejected by the
Syntactic analyzer.
Example of Syntactic Analysis in NLP
Syntactic analysis in NLP involves parsing a
sentence to understand its grammatical
structure. Here’s an example:
Sentence: “The quick brown fox jumps over the
lazy dog.”
Tokenization: The first step is to tokenize the
sentence, breaking it down into individual words:

•“The” | “quick” | “brown” | “fox” | “jumps” | “over”


| “the” | “lazy” | “dog” | “.”
Here’s a simplified representation of the dependency structure:

In this dependency parse tree:

•“jumps” is the main verb, and “fox” is the


sentence’s subject.

•“fox” and “dog” are nouns, and “quick” and


“lazy” are adjectives modifying them.

•“over” is a preposition that connects


“jumps” and “dog.”
3. Semantic Analysis

Semantic analysis is concerned with the meaning


representation.

It mainly focuses on the literal meaning of words,


phrases, and sentences.

4. Discourse Integration

Discourse Integration depends upon the sentences that


proceeds it and also invokes the meaning of the
sentences that follow it.
5. Pragmatic Analysis

Pragmatic is the fifth and last phase of NLP.

It helps you to discover the intended effect by


applying a set of rules that characterize
cooperative dialogues.

For Example: "Open the door" is interpreted as


a request instead of an order.
Lexical or Morphological
Analysis

Syntactic Analysis

Semantic Analysis

Discourse Integration

Pragmatic Analysis
The study of word formation - Morphological

How words are built from smaller pieces.

Identification, analysis of root-words, affixes, parts of


speech

Example:
• Washing= wash + ing
(root word + affix )
• Browser =Browse +er
Find out the pieces that have contributed in word
formation.

Separating or tokenising the words.

Removal of additional words like 's', 'ed’.

Same as tokenization in compilers.


Recognize root forms of inflected words and construc
standardized representation

Books= book + PL, skated =skate + PAST.


Translate contractions (for example, he'll→ he will).
Syntactic Analysis
❑ Check syntactic structure & its components .
❑ Generates a parse tree.
❑ Parse tree: Representation for a sentence into a
structure.
❑ Hierarchical in nature.
❑ Grammar is needed to construct parse tree.
❑ Grammar: description of language, comprises of
rules.
❑ Context Free grammar is used.
❑ "The school goes to boy" is rejected
A context-free grammar (CFG)
Definition - A context-free grammar (CFG) consists of a
finite set of grammar rules is a quadruple (N, T, P, S)
where

N is a set of non-terminal symbols.

T is a set of terminals where N ∩ T = NULL.

P is a set of rules, P: N→ (N UT)*, i.e., the left-hand side of

the production rule P does have any right context or left


The grammar ({A}, {a, b, c}, P, A), P: A→ aA, A → abc.
A- Start symbol(non terminal)
a,b,c- terminal
P-production Rules
A-Start symbol

The grammar ({S, a, b}, {a, b}, P, S), P: S→ aSa, S→ bSb,


S→ε
S-start symbol(non-terminal)
a,b –terminal
P-production rule
S-start symbol
[Link] ate the delicious cake. [Link] read the interesting
book.

S:Sentence →SB VP OB ie subject verb phrase object

SB: Subject →PN i.e. proper noun

VP: Verb Phrase → ADV V | V


OB: Object → the S1

S1: Subset of S→ ADJ | N

PN: Proper Noun → Ram

ADJ: Adjective → interesting | delicious


Once we have the grammar, parse tree is generated
Transformational Grammer

CFG- CONTEXT FREE GRAMMER TG-Transformation grammer TR-Transformation Rules


Top down parsing
❑ Begin with start symbol
❑ Apply the rules till the terminals (leaves)
becomes the symbols of sentences.

Bottom Up Parsing
❖ Begin with sentence.
❖ Apply rules in backward fashion, by
replacing the words in sentence with
appropriate rules till start symbol is reached.
Semantic Analysis
It draws the exact meaning or the dictionary
meaning from the text.
The text is checked for meaningfulness.
Represent sentences in meaningful parts.
Mapping syntactic structures and objects in the task
domain.
Disregards sentence such as "hot ice-cream".
"colorless green idea." This would be rejected by
the Symantic analysis as
colorless Here; green doesn't make any sense.
The keys, which were needed to access the
building, were locked in the car." The result of
semantic role labelling.
Lexical processing
Word Sense Disambiguation Semantic Grammars

S→ Action the Food

Action eat drink | shallow | chew

Food burger | sandwich | coke | pizza


Michael Jordan is a professor at
Berkeley."
Discourse Integration
Written or spoken communication or debate.
Closely related to pragmatics
• The meaning of any sentence depends upon the meaning of
the sentence just before it.
• In addition, it also brings about the meaning of immediately
succeeding sentence.
• It deals with how the immediately preceding sentence can
affect the interpretation of the next sentence.
Bill had a red balloon.
John wanted it.
She wanted it; depends upon the prior discourse context.
• Study of texts and context of language.
• Understanding a text
• Who/when/where/what... are involved in an
event?
• How to connect the semantic representations
of different sentences?
• What is the cause of an event and what is
the consequence of an action?
Pragmatic Analysis
It deals with using and understanding sentences in
different situations and how the interpretation of the
sentence is affected.
Deals with outside word knowledge, which means
knowledge that is external to the documents and/or
queries.
Focuses on what was described is reinterpreted by
what it actually meant.
Involves deriving those aspects of language which
require real world knowledge.
"close the window?" should be interpreted as a request
instead of an order.
Deals with context of sentence.
• Attempt to classify the full variety of the
inferences that any hearer or reader can make
when encountering the locations of the author or
speaker.
• Proper knowledge base
• Context, relation among sentences.
• Translate the knowledge based representation to
a command to be executed by the system.
• Deals with invisible meaning of words.
Uses context of utterance
Where, by who, to whom, why, when it was said
Intentions: inform, request, promise, criticize, ...
Handling Pronouns
"Mary eats apples. She likes them."
She="Mary", th&m="apples".
Handling ambiguity
Pragmatic ambiguity: "you're late": What's the
speaker's intention: informing or criticizing?

You might also like