Natural Language Processing
Natural Language Processing
Chapter 1: Introduction
Mr. Prakash C O
Asst. Professor,
Dept. of CSE, PESU,
coprakasha@[Link]
1
SNLP
Course Objectives:
Understand the business relevance of speech and natural language
technologies
Introduce the basic models used for processing speech and natural
language
Hidden Markov models are especially known for their application in reinforcement
learning and temporal pattern recognition such as speech, handwriting, gesture
recognition, part-of-speech tagging.
[Link]
Course info 2
Text books & references
1 2 3 4
1. [Link]
2. [Link]
(1) Primary text : This is the 3rd and not yet published edition that we will use ;
freely downloadable ; 2nd edition print copy available but many topics are
not there
(2) Use it to learn NLTK in Python
(3) Pdf may be available in net but essentially rely on your faculty
(4) Can be used for keras based coding. Alternatively you can just look at
[Link]
3
SNLP
Important Terminologies
Natural Language
A natural language is any language that has evolved naturally
in humans through use and repetition without conscious planning or
premeditation.
Natural languages can take different forms, such as speech, text or signing
4
SNLP
Important Terminologies cont…
Linguistics
Linguistics is the scientific study of language, including its grammar,
semantics, phonetics and Pragmatics.
Computational Linguistics
Computational linguistics (CL) is the application of computer science
to the analysis, synthesis and comprehension of written and spoken
language.
Semantics
6
SNLP
Important Terminologies cont…
7
SNLP
Important Terminologies cont…
Morphology
Natural
Machine Language
learning Processing
10
SNLP
The ultimate goal of NLP is for computers to achieve human-like
comprehension of texts/languages. When this is achieved, computer
systems will be able to
understand,
summarize,
11
SNLP
NLP Goals
Science Goal: Understand the way language operates
NLP Research
NLP plays a critical role in supporting machine-human
interactions.
13
SNLP
NLP Research
[Link]
[Link]
processing/
[Link]
[Link]
language-models/
14
SNLP
What is NLP used for?
NLP is the driving force behind the following common applications:
15
SNLP
NLP Applications
Text Classification
Language Modeling
Speech Recognition
Caption Generation
Machine Translation
Document Summarization
Question Answering
16
Stages of language processing
Morphology
Lexical Analysis
Syntactic Analysis
Semantic Analysis
Pragmatics
Discourse
17
Phonetics and Phonology
Phonetics - Processing of speech
Phonetics is a branch of linguistics that studies the sounds of human
speech.
It deals with
the sounds of speech and their production,
combination,
description, and
18
Phonetics and Phonology- Ambiguity
Homophones - (sound the same-different meanings and different spellings)
alter (change) vs. altar (table in church where bread and wine are kept)
The word Good in the following two examples. In one case it’s a moral
judgement, in the other case it’s a judgement of skill.
2. Bill was a good painter. His drawings always were exciting to look at. 19
Phonetics and Phonology
Phonology:
20
Morphology
In linguistics, morphology is the study of words, how they are formed
using morphemes, and their relationship to other words in the same
language.
Morphology analyzes
The structure of words and
The parts of words, such as stems, root words, prefixes, and suffixes.
Morphology is the study of the way words are built up from smaller
meaning-bearing units called morphemes.
21
Lexical Analysis
Lexical Level: This level of speech analysis examines
how the parts of words (morphemes) combine to make words and
e.g. dog
22
Lexical Disambiguation
First step: Disambiguate part of Speech
Dog as a noun
Dog as a verb
Dog(Verb):
1. Follow (someone) closely and persistently.
2. Somebody/something (of a problem or bad luck) to cause you trouble for a long time.
23
Even lexicon has to change
25
Syntax Processing Stage
Disambiguate by Structure Detection ( “ I like mangoes”)
VP
NP
V NP
I
like
mangoes
26
Syntactic Processing: Structural Ambiguity
Camera man shot the man with the gun when he was near
Tendulkar
1. Two meanings of “shot”
28
Anaphora resolution
1. Anaphora resolution :
“The empress has not arrived but she should be here any moment.”
“she” is the anaphora
Anaphora : the use of a word referring back to a word used earlier in a text or
conversation, to avoid repetition.
Antecedent: It is an expression (word, phrase, clause, sentence, etc.) that gives its
meaning to a proform (pronoun, pro-verb, pro-adverb, etc.). 29
Higher level knowledge needed for disambiguation
Semantics helped
I saw the boy with a pony tail (pony tail cannot be an instrument
of seeing)
It is the first part of the semantic analysis in which the study of the meaning of
individual words is performed. This part is called lexical semantics.
In the second part, the individual words will be combined to provide meaning in
sentences.
The most important task of semantic analysis is to get the proper meaning of the
sentence.
In this sentence, the speaker is talking either about Lord Ram or about a person
whose name is Ram. That is why the job, to get the proper meaning of the
sentence, of semantic analyzer is important.
31
Semantic Analysis
Knowledge representation in terms of
Predicate calculus/Semantic Nets/Frames/Conceptual
Dependencies and Scripts
32
Pragmatics
Pragmatic Level:
Based on meaning of words or sentences on situational awareness and
world knowledge. Basically, what meaning is most likely and would make
the most sense.
Boy (running upstairs and coming back panting): yes sir, they are there.
2. World knowledge
WHY INDIA NEEDS A SECOND OCTOBER (ToI, 2/10/07)
33
Discourse
Discourse - analysis of language 'beyond the sentence'
It is language identified by the social conditions of its use, by who is using it and
under what conditions.
34
Discourse
Discourse Level:
How sentences relate to one another. Sentence order and arrangement
can affect the meaning of the sentences.
Mother to John:
John go to school. It is open today. Should you bunk? Father will be very angry.
A. Ambiguity of open
B. bunk what?
C. Why will the father be angry?
D. Ambiguity of father
father as parent
or
father as headmaster
35
Complexity of Connected Text
John was returning from school dejected – today was the math test
36
Components of NLP systems
Five major elements: the parser, the lexicon, the semantic analyser,
the knowledge base, and the generator
37
SNLP
38
Morphology
Why Morphology?
39
Morphology
Prerequisites
Affixes
Inflection
41
Morpheme
What is morpheme? Cont…
42
Morpheme
Morphemes are comprised of two separate classes(components)
called
2. affixes.
A "base," or "root" is a morpheme in a word that gives the word its
principle meaning.
43
Morpheme
Classification of morphemes
Function words
1. Bound morphemes
Bound morphemes are of two types which include:
Derivational Morphemes 44
Morpheme
Classification of morphemes
1. Free morphemes:
Free morphemes can function independently as words
(e.g. town, dog) and can appear within lexemes (e.g. town
hall, doghouse).
Pronouns - I, you, we, they, he, she, it, me, us, them, him, her, this, those.
Prepositions - at, on, in, from, with, near, between, about, under.
Conjunctions - and, or, but, because, so, yet, since, if.
46
Morpheme
Classification of morphemes
2. Bound morphemes:
A bound morpheme is used with a free morpheme to construct a new
word, as it cannot stand independently (it cannot stand alone with
meaning).
Derivational Morphemes
derivation deals with the creation of new words from existing words.
48
Morpheme
Inflectional morphemes
An inflectional morpheme changes the form of a word.
(play=>played/playing, sing=>sings)
49
Morpheme
Inflectional Affixes
There are only eight "inflectional affixes" in English, and these are
all suffixes.
For example,
In the word happiness, the addition of the bound morpheme -ness to the
root happy changes the word from an adjective (happy) to a noun (happiness).
In the word unkind, un- functions as a derivational morpheme since it inverts the
meaning of the word formed by the root kind.
This type of morpheme uses both prefix as well as suffix, and has
the ability to change function as well as meaning of words.
51
Morpheme
A third way of classifying morphemes relies on the kinds of
meanings they encode.
Grammatical morphemes
Lexical morphemes
52
Morpheme
semantic analysis
55
SNLP - Techniques used in NLP
Syntax Analysis
56
SNLP - Techniques used in NLP
Syntax Analysis techniques:
Lemmatization:
Morphological segmentation:
Word segmentation:
57
SNLP - Techniques used in NLP
Syntax Analysis techniques: cont…
provided sentence.
form.
58
SNLP - Techniques used in NLP
Semantic Analysis
Semantics refers to the meaning that is conveyed by a text.
59
SNLP - Techniques used in NLP
Semantic Analysis techniques:
Named entity recognition (NER): It involves determining the parts
of a text that can be identified and categorized into preset
groups.