CS460/626 : Natural Language Processing/Speech NLP and the Web Processing/Speech, NLP and the Web (Lecture 28– Grammar; Constituency, Dependency) Dependency) Pushpak Bhattacharyya Pushpak Bhattacharyya CSE Dept., IIT Bombay 21 t M h 2011 21 st March, 2011
47
Embed
CS460/626 : Natural Language Processing/Speech NLP and the ...
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
CS460/626 : Natural Language Processing/Speech NLP and the WebProcessing/Speech, NLP and the Web
A finite set of rules that generates only and all sentences of athat generates only and all sentences of a language.that assigns an appropriate structural g pp pdescription to each one.
Grammatical Analysis Techniques
Two main devices
Breaking up a StringLabeling the Constituents
– MorphologicalC i l
– SequentialHi hi l – Categorial
– Functional – Hierarchical– Transformational
Breaking up and LabelingSequential Breaking up
Seq enti l B e king p nd Mo phologi lSequential Breaking up and Morphological LabelingSequential Breaking up and Categorial Labeling Seque a ea g up a d Ca ego a abe gSequential Breaking up and Functional Labeling
Hierarchical Breaking upHierarchical Breaking upHierarchical Breaking up and Categorial LabelingHierarchical Breaking up and Functional Labelingg p g
Sequential Breaking up
• That student solved the problems.
that student solve ed the problem s+ + + + + +
Sequential Breaking up and Morphological LabelingMorphological Labeling
That student solved the problems.
th t t d t l d h blthat student solve ed the problem s
word word stem affix word stem affix
Sequential Breaking up and Categorial LabelingCategorial Labeling
This boy can solve the problem.this boy can solve the problem
Det N Aux V Det N
• They called her a taxi.They call ed taxi
Pron V Affi N
her
P on
a
DetPron V Affix NPron Det
Sequential Breaking up and Functional LabelingFunctional Labeling
SubordinationSubordinationJohn slept [in]subordinator [the room]dependent unit
S
PredicateSubject
John Head Modifier
slept Subordinator Dependent Unit
the roomin
Coordination
[John came in time] independent unit [but]coordinatorp[Mary was not ready] independent unit
SS
C di tI d d t U it Independent UnitCoordinatorIndependent Unit Independent Unit
John came in time but Mary was not ready
An Example
SIn the morning, the sky looked much brighter.An Example
S
HeadModifier
Subordinator DU PredicateSubject
HeadHead Verbal ComplementModifierModifier
HeadModifier
In the morning, the sky looked much brighter
Hierarchical Breaking up and Categorial / Functional LabelingCategorial / Functional Labeling
Hierarchical Breaking up coupled with C t i l /F ti l L b li iCategorial /Functional Labeling is a very powerful device.B t th bi iti hi hBut there are ambiguities which demand something more powerful.E L f G dE.g., Love of God
Someone loves GodG d lGod loves someone
Hierarchical Breaking up
Categorial Labeling Functional Labeling
Love of God Love of God
Noun Ph
Prepositional Phrase
Head ModifierPhrase Phrase
DUSub
Godoflove love of God
Types of Generative GrammarypFinite State Model
( i l)(sequential)Phrase Structure Model
(sequential + hierarchical) + (categorial)
Transformational ModelTransformational Model (sequential + hierarchical + transformational) +
A phrase-structure grammar G consists of a f t l (V T S P) hfour tuple (V, T, S, P), where V is a finite set of alphabets (or vocabulary)
E g N V A Adv P NP VP AP AdvP PPE.g., N, V, A, Adv, P, NP, VP, AP, AdvP, PP, student, sing, etc.
T is a finite set of terminal symbols: T ⊂ VT is a finite set of terminal symbols: T ⊂ VE.g., student, sing, etc.
S is a distinguished non-terminal symbol, also g y ,called start symbol: S ∈ VP is a set of productions.
Noun Phrases
• John • the student • the intelligent student
NP NP NPNP
N
NP
NDet
NP
NDet AdjP
John studentthe studentthe intelligent
j
Noun Phrase
• his first five PhD students
NP
QuantDet Ord NN
five
Quant
his
Det
first
Ord
students
N
PhD
N
fivehis first studentsPhD
Noun PhraseNoun Phrase• The five best students of my class
NP
fi
Quant
th
Det NAP PP
fivethe studentsbest of my class
Verb Phrases• can sing • can hit the ball
VP VPVP
VAux
VP
NPAux V
singcan the ball
NP
can
Aux
hit
V
g
Verb PhraseVerb Phrase• Can give a flower to Mary
VP
NPAux V PP
a flower
NP
can
Aux
give
V
to Mary
PP
g o a y
Verb Phrase• may make John the chairman
VP
NPAux V NP
John
NP
may
Aux
make
V
the chairman
NP
y e c a a
Verb Phrase
• may find the book very interesting
VP
NPAux V AP
the bookmay find very interesting
Prepositional Phrases
• in the classroom • near the river
PPPP
NPPNPP
the rivernearthe classroomin
Adjective PhrasesAdjective Phrases• intelligent • very honest • fond of sweets
AP AP AP
A ADegree PPA
intelligent honestvery of sweetsfond
Adjective Phrase
• very worried that she might have done badly in the i tassignment
AP
S’Degree A S
very
Degree
worried
A
that she might have done badly in the
very worried
assignment
Phrase Structure Rules
Rewrite Rules:
• The boy hit the ball.
Rewrite Rules:(i) S NP VP(ii) NP D t N(ii) NP Det N(iii) VP V NP
h(iv) Det the(v) N man, ball(v) V hit
We interpret each rule X Y as the instruction rewrite X as Y.
DerivationDerivation• The boy hit the ball.
SentenceNP + VP (i)Det + N + VP (ii)Det + N + V + NP (iii)The + N + V + NP (iv)The + N + V + NP (iv)The + boy + V + NP (v)The + boy + hit + NP (vi)The + boy + hit + Det + N (ii)The + boy + hit + the + N (iv)The + boy + hit + the + ball (v)The + boy + hit + the + ball (v)
PSG Parse Tree
The boy hit the ball.S
VPNP
VND t NPVNDet
the
NP
Nb Dethitthe Nboy Dethit
the ballthe ball
PSG Parse Tree
John wrote those words in the Book of ProverbsSProverbs.S
• Official trading in the shares will start in Paris on Nov 6
( (S (NP-SBJ (NP Official trading)(PP in
Nov 6.
(PP in(NP the shares)))
(VP will(VP start(PP-LOC in
(NP Paris))(NP Paris))(PP-TMP on
(NP (NP Nov 6)( ( )
Penn POS Tag SsetAdjective: JJAdverb: RBCardinal Number: CDDeterminer: DTPreposition: INCoordinating Conjunction CCSubordinating Conjunction: INSingular Noun: NNPlural Noun: NNSPlural Noun: NNSPersonal Pronoun: PPProper Noun: NPVerb base form: VBVerb base form: VBModal verb: MDVerb (3sg Pres): VBZWh-determiner: WDTWh determiner: WDTWh-pronoun: WP
Diff b tDifference between constituency and dependencyconstituency and dependency
Constituency GrammarConstituency GrammarCategorical Uses part of speechContext Free Grammar (CFG)Basic elements Phrases
Dependency Grammar
FunctionalContext Free GrammarContext Free GrammarBasic elements Units of Predication/ Modification/ Complementation/Modification/ Complementation/ Subordination/ Co-ordination
Bridge between Constituency and Dependency parse
Constituency uses phrasesDependencies consist of Head-modifier combinationThis is a cricket bat.This is a cricket bat.
Cricket (Category: N, Functional: Adj)Bat (Category: N, Functional: N)
For languages which are free word order we use g gdependency parser to uncover the relations between the words.Raam ne Shaam ko dekha . (Ram saw Shyam)Sh k R d kh (R Sh )Shaam ko Ram ne dekha. (Ram saw Shyam)Case markers cling to the nouns they subordinate
For a single sentence we can have multiple parsesparses. Probability for the parse is calculated and then the parse with the highest probabilitythen the parse with the highest probability is selected.This is needed in many applications of NLP,This is needed in many applications of NLP, that need parsing.