0% found this document useful (0 votes)
6 views60 pages

Natural Language Processing

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

Natural Language Processing

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

UE19CS562:

Speech And 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.

 N-gram models: Used to build simple language models.

 Work with tools to perform speech/natural language processing.

 [Link]

 Gain a practical insight into solving these problems. (Mini-project)

 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.

 Computational linguistics is used in


instant machine translation, speech recognition (SR) systems,
text-to-speech (TTS) synthesizers, interactive voice response (IVR) systems,
search engines, text editors and language instruction materials.
5
SNLP
 Important Terminologies cont…

 Semantics

 Scientific study of meaning in natural and artificial languages.

 It is concerned with the relationship between signifiers—


like words, phrases, signs, and symbols—and what they stand
for in reality, their denotation.

 Semantics: the study of language meaning. The meaning of a


word, phrase, sentence, or text.

6
SNLP
 Important Terminologies cont…

 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 representation by
written symbols.

 A phoneme is the smallest sound unit in a language that is


capable of conveying a distinct meaning, such as
the s of sing and the r of ring.

7
SNLP
 Important Terminologies cont…

 Pragmatics - gives context to Language.

 Pragmatics is a branch of linguistics concerned with the use of


language in social contexts and the ways people produce
and comprehend meanings through language.

 Morphology

 In linguistics, morphology is the study of words, how they are


formed, and their relationship to other words in the same
language.

 It analyzes the structure of words and parts of words, such


as stem/root/base words and affixes (prefixes and suffixes).
8
SNLP
 What is Natural Language Processing?
 NLP is the technology used to aid computers to understand the
human’s natural language.

It’s not an easy task teaching machines to understand how we communicate.

 NLP is the relationship between computers and human


language.
More specifically, NLP is the computer understanding, analysis,
manipulation, and/or generation of natural language

 NLP is known as computational linguistics, is the combination


of ML, AI, and linguistics that allows us to talk to machines as if
they were human.
9
SNLP
 What is Natural Language Processing?
 NLP, is a branch of AI that deals with the interaction between
computers and humans using the natural language.

 The ultimate objective of NLP is to read, decipher, understand,


and make sense of the human languages in a manner that is
valuable.
Artificial
Intelligence(AI)

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,

 draw inferences from,

 summarize,

 translate and generate accurate and natural human text and


language.

11
SNLP
 NLP Goals
 Science Goal: Understand the way language operates

 Engineering Goal: Build systems that analyze and generate


language; reduce the man machine gap

 NLP Research
 NLP plays a critical role in supporting machine-human
interactions.

 As more research is being carried in this field, we expect to see


more breakthroughs that will make machines smarter at
recognizing and understanding the human language.
12
SNLP
 NLP Research
 In 2018 we saw a number of landmark research breakthroughs in
the field of natural language processing (NLP).

The introduction of transfer learning and pretrained language


models in NLP pushed forward the limits of language understanding
and generation.

 Several advances in natural language processing (NLP), including

 high-performing transfer learning techniques,

 more sophisticated language models, and

 newer approaches to content understanding.

13
SNLP
 NLP Research
 [Link]

 Efficient Smart Reply, now for Gmail

 [Link]
processing/

 [Link]

 [Link]
language-models/

14
SNLP
 What is NLP used for?
NLP is the driving force behind the following common applications:

 Language translation applications such as Google Translate.


 [Link]

 Word Processors such as Microsoft Word and Grammarly that employ


NLP to check grammatical accuracy of texts.
 [Link] [Link]

 Interactive Voice Response (IVR) applications used in call centers to


respond to certain users’ requests.

 Personal assistant applications such as OK Google, Siri, Cortana, and


Alexa.

15
SNLP
 NLP Applications
 Text Classification

 Language Modeling

 Speech Recognition

 Caption Generation

 Machine Translation

 Document Summarization

 Question Answering

 Applications of Deep Learning for Natural Language Processing

16
Stages of language processing

 Phonetics and Phonology

 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

 representation by written symbols.

 A phoneme is the smallest sound unit in a language that is capable


of conveying a distinct meaning, such as the s of sing and
the r of ring.

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)

 loan vs lone etc.

 Homonymy – (Words have unrelated meaning) words sound the same


(homophones), same spelling (homographs), but do not have related
meanings.

 bank (finance) vs. bank (river bank)

 Polysemy - (Words have related meaning) refers to the coexistence of


many possible meanings for a word or phrase.

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.

1. John was a good man. He donated a lot of money to charity.

2. Bill was a good painter. His drawings always were exciting to look at. 19
Phonetics and Phonology
 Phonology:

 It is the study of sound structures in language.

 It is a branch of linguistics concerned with the systematic


organization of sounds in spoken languages and signs in sign
languages.

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

 how slight differences can dramatically change the meaning of the


final word.

 Disambiguate by referring to dictionary (lexicon)

e.g. dog

noun (lexical property)


take-’s’-in-plural (morph property)
animate (semantic property)
4-legged (-do-)
carnivore (-do)

22
Lexical Disambiguation
First step: Disambiguate part of Speech

 Dog as a noun

 Dog as a verb

Second step: Disambiguation Sense

 Dog (as animal)

 Dog (as a problem, bad luck, trouble, follow somebody closely)


Photographers seemed to dog her every step. She had been dogged by ill health all his
life. Her career was dogged by misfortune.

“Words have many meanings. We need to decide which meaning by


understanding the context !”

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

 Justify as in justify the right margin (word processing context)

 Xeroxed: a new verb

 Digital Trace: a new expression

 Helicopter Parenting: over parenting (overcontrolling,


overprotecting, and overperfecting)

 A lexicon (wordbook, or word-stock )is the vocabulary of a person,


language, or branch of knowledge.
 In linguistics, a lexicon is a language's inventory of lexemes.
 Items in the lexicon are called lexemes, or lexical items, or word forms.
 Lexemes are not atomic elements but contain both phonological and
morphological components. 24
Syntactic Analysis
 Syntactic Analysis:
 This level focuses on text at the sentence level.

 Syntax revolves around the idea that in most languages the


meaning of a sentence is dependent on word order and
dependency.

25
Syntax Processing Stage
Disambiguate by Structure Detection ( “ I like mangoes”)

VP
NP

V NP

I
like
mangoes
26
Syntactic Processing: Structural Ambiguity

 Disambiguate by understanding scope (region of influence)

[Link] old men and women were taken to safe locations

(influence of “old”). While the cause of the ambiguity is scope of


“old”, the answer to this ambiguity is provided by “pragmatics” !

2. No smoking areas will allow Hookas inside

(influence of “No” i.e. not any)

 Disambiguate by preposition phrase attachment

1. I saw the boy with a telescope

(Is the telescope a qualifier for the boy?)

I saw the mountain with the telescope ( no ambiguity as mountain


cannot have a telescope)
27
Syntactic Processing: more Structural Ambiguity

 Camera man shot the man with the gun when he was near
Tendulkar
1. Two meanings of “shot”

2. Two preposition phase attachments i.e. “with the gun”

3. Where does the pronoun “he” attach to ?

4. Already 2x2x2 meaning possibilities

28
Anaphora resolution
1. Anaphora resolution :
“The empress has not arrived but she should be here any moment.”
 “she” is the anaphora

 “The empress” is the antecedent

Both refer to the same world entity

2. Cataphora : when anaphora precedes the antecedent


 Because she was going to post office, Madhu was asked to post a
parcel.

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)

 Pragmatics (modeling user intention and world knowledge ) helped


 ((old men) and women) as opposed to (old men and women) in
“Old men and women were taken to safe location”
 since women, both young and old, were very likely taken to safe
locations

 Discourse helped (other segments of sentences)


 No smoking areas allow hooka inside, except the one at Hotel
Oberoi Grand
30
Semantic Analysis
 Semantic Analysis: The work of semantic analyzer is to check the text for
meaningfulness.

 Studying meaning of individual word

 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.

 Studying the combination of individual words

 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.

 For example, analyze the sentence “Ram is great.”

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

 John gave a book to Mary


 Semantic roles
 Action: give, Agent: John, Object: Book, Recipient: Mary

 Challenge: ambiguity in semantic role labeling


 Visiting aunts can be a nuisance

 Aunt can be both agent and object !

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.

1. Model user intention


 Tourist (in a hurry, checking out of the hotel, motioning to the service
boy): Boy, go upstairs and see if my sandals are under the divan. Do not
be late. I just have 15 minutes to catch the train.

 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'

 In linguistics, discourse refers to a unit of language longer than a single


sentence.

 To study discourse is to analyze the use of spoken or written language in a


social context.

 "Discourse in context may consist of


 only one or two words as in stop or no smoking.
 hundreds of thousands of words as in novels, essays, notices …

 "Discourse is the way in which language is used socially to convey broad


historical meanings.

 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.

 Processing of sequence of sentences

 Complex chain of reasoning and application of world knowledge !

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

He couldn’t control the class ( student ? )

Teacher shouldn’t have made him Responsible (monitor ? )

After all he is just a janitor ( neither of the above !)

We are forming hypothesis and discarding after we encounter new


evidence !!

36
Components of NLP systems
 Five major elements: the parser, the lexicon, the semantic analyser,
the knowledge base, and the generator

37
SNLP

Survey of English Morphology

38
Morphology

 Morphology is the study of how words are composed of


morphemes (the smallest meaning-bearing units of a language)

 Why Morphology?

 The most sophisticated methods for lemmatization involve


complete morphological parsing of the word.

39
Morphology

 Prerequisites

 Difference between Root, Stem and Base in linguistics

 Affixes

 Inflection

"In grammar, inflection is the modification of a word to express different

grammatical categories such as tense, case, voice, aspect, person,

number, gender, and mood. An inflection expresses one or more

grammatical categories with a prefix, suffix or infix, or another internal

modification such as a vowel change"


40
Morpheme
 What is morpheme?
 It is the “smallest meaning-bearing unit” in a given language.

 A morpheme is not identical to a word.


The main difference between them is that a morpheme sometimes
does not stand alone, but a word, by definition, always stands alone.

 When a morpheme stands by itself, it is considered as a root because it


has a meaning of its own (such as the morpheme cat).

41
Morpheme
 What is morpheme? Cont…

 When morpheme depends on another morpheme to express an idea, it


is an affix because it has a grammatical function (such as the –
s in cats to indicate that it is plural).

 Every word comprises one or more morphemes.

The word ‘untouchables’ has four morphemes.


The root ‘touch’, the suffix ‘-able’, then the prefix ‘un-‘ and finally the
suffix ‘-s’.

42
Morpheme
 Morphemes are comprised of two separate classes(components)
called

1. bases (or roots) and

2. affixes.
 A "base," or "root" is a morpheme in a word that gives the word its
principle meaning.

 An example of a "free base" morpheme is woman in the word womanly.

 An example of a "bound base" morpheme is -sent in the word dissent.

43
Morpheme
Classification of morphemes

 Every morpheme can be classified as either free or bound.


Since the categories are mutually exclusive, a given morpheme will
belong to exactly one of them.
1. Free morphemes
Free morphemes can be further subdivided into

 Content words and

 Function words

1. Bound morphemes
Bound morphemes are of two types which include:

 Inflectional Morphemes and

 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).

 Free morphemes can stand alone with a specific meaning, for


example, eat, date, weak.

 Free morphemes are autonomous, can occur on their own and


are thus also words at the same time.

 Free morphemes cannot be broken down further into other


word elements.
45
Morpheme
 "Free morphemes can be further classified into content words and
function words.
 Content words, as their name suggests, carry most of the content of a
sentence.

Examples: eat, run, sleep, talk, paint, ……

 Function words have little lexical meanings but have importance in


sentence structure. Typically they are prepositions, pronouns,
conjunctions etc.

Examples: to, that, and, there, some, but, ….

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).

 Bound Morphemes appear only as parts of words, always in conjunction


with a root and sometimes with other bound morphemes.

 Most bound morphemes in english are affixes. Generally, affixes used


with a root word are bound morphemes.

 For example, in “The farmer wants to kill duckling,” the bound


morphemes “er,” “s,” and “ling” cannot stand on their own. They need
free morphemes of “farm,” “want” and “duck” to give meanings.
47
Morpheme

 Bound morphemes are of two types which include:


 Inflectional Morphemes and

 Derivational Morphemes

 Inflectional morphology differs from derivational morphology in that


 inflection deals with changes made to existing words and

 derivation deals with the creation of new words from existing words.

 Both inflection and derivation involve attaching affixes to words, but


 inflection changes a word's form, maintaining the same word, and

 derivation changes a word's category, creating a new word.

48
Morpheme
Inflectional morphemes
 An inflectional morpheme changes the form of a word.

 This type of morpheme is only a suffix.

 Inflectional morphemes modify


 the tense, person(3SG), of a verb, or

(play=>played/playing, sing=>sings)

 the number, gender, or case of a noun, adjective, or pronoun,

(city=>cities, tiger=>tigress, Pratham=>Pratham's, ….)

without affecting the word's meaning or class (part of speech).

49
Morpheme
Inflectional Affixes

 There are only eight "inflectional affixes" in English, and these are
all suffixes.

 English has the following inflectional suffixes, which serve a variety of


grammatical functions when added to specific types of words.

 These grammatical functions are shown to the right of each suffix.

suffix Creates Example


-s noun - plural towns
-'s noun - possessive Pratham’s, Kate’s
-s verb - present tense third person singular Likes, Sings

-ing verb - present participle/gerund reading


-ed verb - simple past tense walked
-en verb - past perfect participle eaten
-er adjective - comparative brighter
50
-est adjective - superlative brightest
Morpheme
Derivational morphemes

 Derivational morphemes, when combined with a root, change the


semantic meaning or the part of speech of the affected word.

 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

 Grammatical morphemes serve the purpose of signaling


grammatical categories and encoding relational meanings

 Lexical morphemes carry richer conceptual, more autonomous


meanings.

52
Morpheme

As shown in Table 1, inflectional morphemes form the subclass of bound


grammatical morphemes, whereas derivational morphemes are bound lexical
morphemes. 53
54
SNLP
 What are the techniques used in NLP?
 Syntactic analysis and

 semantic analysis

are the main techniques used to complete NLP tasks.

55
SNLP - Techniques used in NLP
Syntax Analysis

 Syntax refers to the arrangement of words in a sentence such that


they make grammatical sense.

 In NLP, syntactic analysis is used to assess how the natural


language aligns with the grammatical rules.

 Computer algorithms are used to apply grammatical rules to a


group of words and derive meaning from them.

56
SNLP - Techniques used in NLP
 Syntax Analysis techniques:
 Lemmatization:

It entails reducing the various inflected forms of a word into a


single form for easy analysis.

 Morphological segmentation:

It involves dividing words into individual units called morphemes.

 Word segmentation:

It involves dividing a large piece of continuous text into distinct


units.

57
SNLP - Techniques used in NLP
Syntax Analysis techniques: cont…

 Part-of-speech tagging: It involves identifying the part of speech

for every word.

 Parsing: It involves undertaking grammatical analysis for the

provided sentence.

 Sentence breaking: It involves placing sentence boundaries on

a large piece of text.

 Stemming: It involves cutting the inflected words to their root

form.

58
SNLP - Techniques used in NLP
 Semantic Analysis
 Semantics refers to the meaning that is conveyed by a text.

 Semantic analysis is one of the difficult aspects of Natural


Language Processing that has not been fully resolved yet.

 It involves applying computer algorithms to understand the


meaning and interpretation of words and how sentences are
structured.

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.

Examples of such groups include names of people and names


of places.

 Word sense disambiguation: It involves giving meaning to a


word based on the context.

 Natural language generation: It involves using databases to


derive semantic intentions and convert them into human
language.
60

You might also like