lecture 7: language structure: grammarcs6501: nlp 4 a better model cs6501: nlp 5 language is...
TRANSCRIPT
Lecture 7:Language Structure:
Grammar
Kai-Wei ChangCS @ UCLA
Couse webpage: https://uclanlp.github.io/CS269-17/
1ML in NLP
Basic sentence structure
CS6501: NLP 2
A Markov Model
v I eat shshi; I eat meat; you eat banana…
vGreat, it covers many sentences
CS6501: NLP 3
Words take different arguments
v [Good] I eat sushiv [Bad] I run sushiv [Bad] I give sushi
v Intransitive verbs (sleep): no objectv Transitive verbs (eat): take one direct objectv Ditransitive verbs (give): take an additional
indirect object.
CS6501: NLP 4
A better model
CS6501: NLP 5
Language is recursive
CS6501: NLP 6
Adjectivescanmodifynouns.Wecanhaveunlimitedmodifiers(intheory)
We know how to model the simple one
CS6501: NLP 7
Recursion can be more complex
CS6501: NLP 8
Wecanhaveanothernounphraseinpreposition
Syntactic parsing
v Idea: model language as a recursive generating processvOften use a tree structurevDecompose a sentence
CS6501: NLP 9
What is grammar?
vA compact way to define and describe the structure of sentences
vWhy we need grammar?vNumber of C++ programs?
CS6501: NLP 10
976pages.
C++ standard (2014)
ISO/IEC 14882:2014
1358 pages
Can we define a program that generates all English sentences?
CS6501: NLP 11FromJuliaHockenmaier,IntrotoNLP
What is sentence structure
vSentence structure is hierarchicalvA sentence consists of phrases (or
constituents)
CS6501: NLP 12
Can have complex constituents
CS6501: NLP 13
Can have complex constituents
vSyntactically, constituents behave like simple ones
CS6501: NLP 14
Constituency
vGroups of words that behave as a single unit or phrasevE.g., Noun phrases: the man, a girl with glassesvPrepositional phrases: with classes, on a tablevVerb phrase: eat sushi, sleep, sleep soundly
vPhrases has a head:vOther parts called dependentsvE.g, the man, a girl with glasses
CS6501: NLP 15
Properties of constituents
vSubstitutionvHe talks [in class] ⇒ He talks [there]
v It can move around in a sentencevHe talks [in class] ⇒ [In class], he talks.
vCan be used as an answer:vWhere does he talk? – [In class]
CS6501: NLP 16
Types of dependencies
vPhrases has a head:vOther parts called dependentsvE.g, the man, a girl with glasses
vDependents can be arguments or adjunctsvArguments are obligatory
vE.g., [John] likes [Mary]
vAdjuncts are optionalvE.g., John runs [fast] vAdverbs, PPs, Adjectives…
CS6501: NLP 17
Allargumentshavetobepresentandcannotbeoccupiedmultipletimes
Canbeanarbitrarynumberofadjuncts
How to represent the structure
CS6501: NLP 18
Dependency Trees
vDependency grammar describe the structure of sentences as a graph (tree)vNodes represent wordsvEdges represent dependencies
CS6501: NLP 19
Phrases structure trees
vCan be modeled by Context-free grammars
CS6501: NLP 20
Context-free grammars
CS6501: NLP 21
Parse tree defined by CFG
CS6501: NLP 22
Generate sentences by CFG
CS6501: NLP 23
Example: Noun Phrases
CS6501: NLP 24
Example: verb phrase
CS6501: NLP 25
Sentences
CS6501: NLP 26