1 context-free grammars. nle 2 syntactic analysis (parsing) s npvp atnnsvbd np at nnthechildrenate...
Post on 15-Jan-2016
221 views
TRANSCRIPT
![Page 1: 1 CONTEXT-FREE GRAMMARS. NLE 2 Syntactic analysis (Parsing) S NPVP ATNNSVBD NP AT NNthechildrenate thecake](https://reader035.vdocuments.us/reader035/viewer/2022062423/56649d625503460f94a4424f/html5/thumbnails/1.jpg)
1
CONTEXT-FREE GRAMMARS
![Page 2: 1 CONTEXT-FREE GRAMMARS. NLE 2 Syntactic analysis (Parsing) S NPVP ATNNSVBD NP AT NNthechildrenate thecake](https://reader035.vdocuments.us/reader035/viewer/2022062423/56649d625503460f94a4424f/html5/thumbnails/2.jpg)
NLE2
Syntactic analysis (Parsing)
S
NP VP
AT NNS VBD NP
AT NNthe children ate
the cake
![Page 3: 1 CONTEXT-FREE GRAMMARS. NLE 2 Syntactic analysis (Parsing) S NPVP ATNNSVBD NP AT NNthechildrenate thecake](https://reader035.vdocuments.us/reader035/viewer/2022062423/56649d625503460f94a4424f/html5/thumbnails/3.jpg)
NLE4
Beyond regular languages: Context-Free Grammars
S NP VPNP Det NominalNominal NounVP V
Det theDet aNoun flightV left
![Page 4: 1 CONTEXT-FREE GRAMMARS. NLE 2 Syntactic analysis (Parsing) S NPVP ATNNSVBD NP AT NNthechildrenate thecake](https://reader035.vdocuments.us/reader035/viewer/2022062423/56649d625503460f94a4424f/html5/thumbnails/4.jpg)
NLE5
Derivations
A DERIVATION of a string is a sequence of rule applications
– E.g., the string “a flight” can be derived from the grammar above and symbol NP by the (leftmost first) derivation
NP => Det Nominal => a Nominal => a Noun => a flight
Derivations can be visualized as PARSE TREES The LANGUAGE defined by a CFG is the set of strings
derivable from the start symbol S (for Sentence)
![Page 5: 1 CONTEXT-FREE GRAMMARS. NLE 2 Syntactic analysis (Parsing) S NPVP ATNNSVBD NP AT NNthechildrenate thecake](https://reader035.vdocuments.us/reader035/viewer/2022062423/56649d625503460f94a4424f/html5/thumbnails/5.jpg)
NLE6
Derivations and parse trees
![Page 6: 1 CONTEXT-FREE GRAMMARS. NLE 2 Syntactic analysis (Parsing) S NPVP ATNNSVBD NP AT NNthechildrenate thecake](https://reader035.vdocuments.us/reader035/viewer/2022062423/56649d625503460f94a4424f/html5/thumbnails/6.jpg)
NLE7
A more formal definition
A CFG is a 4-tuple <N,,P, S> consisting of
![Page 7: 1 CONTEXT-FREE GRAMMARS. NLE 2 Syntactic analysis (Parsing) S NPVP ATNNSVBD NP AT NNthechildrenate thecake](https://reader035.vdocuments.us/reader035/viewer/2022062423/56649d625503460f94a4424f/html5/thumbnails/7.jpg)
NLE8
What `context free’ means
![Page 8: 1 CONTEXT-FREE GRAMMARS. NLE 2 Syntactic analysis (Parsing) S NPVP ATNNSVBD NP AT NNthechildrenate thecake](https://reader035.vdocuments.us/reader035/viewer/2022062423/56649d625503460f94a4424f/html5/thumbnails/8.jpg)
NLE9
Derivations and languages
The language LG GENERATED by a CFG grammar G is the set of strings of TERMINAL symbols that can be derived from the start symbol S using the production rules in G– LG = {w | w is in * and S derives w}
The strings in LG are called GRAMMATICAL
The strings not in LG are called UNGRAMMATICAL
![Page 9: 1 CONTEXT-FREE GRAMMARS. NLE 2 Syntactic analysis (Parsing) S NPVP ATNNSVBD NP AT NNthechildrenate thecake](https://reader035.vdocuments.us/reader035/viewer/2022062423/56649d625503460f94a4424f/html5/thumbnails/9.jpg)
NLE10
Grammar development
One of the most basic skills in NLE is the ability to write a CFG for some fragment of a language (e.g., the dates)
We’ll briefly cover some of the issues to be addressed when writing small CFG grammars
![Page 10: 1 CONTEXT-FREE GRAMMARS. NLE 2 Syntactic analysis (Parsing) S NPVP ATNNSVBD NP AT NNthechildrenate thecake](https://reader035.vdocuments.us/reader035/viewer/2022062423/56649d625503460f94a4424f/html5/thumbnails/10.jpg)
NLE11
An example lexicon
![Page 11: 1 CONTEXT-FREE GRAMMARS. NLE 2 Syntactic analysis (Parsing) S NPVP ATNNSVBD NP AT NNthechildrenate thecake](https://reader035.vdocuments.us/reader035/viewer/2022062423/56649d625503460f94a4424f/html5/thumbnails/11.jpg)
NLE12
An example grammar
![Page 12: 1 CONTEXT-FREE GRAMMARS. NLE 2 Syntactic analysis (Parsing) S NPVP ATNNSVBD NP AT NNthechildrenate thecake](https://reader035.vdocuments.us/reader035/viewer/2022062423/56649d625503460f94a4424f/html5/thumbnails/12.jpg)
NLE13
A simple parse tree
![Page 13: 1 CONTEXT-FREE GRAMMARS. NLE 2 Syntactic analysis (Parsing) S NPVP ATNNSVBD NP AT NNthechildrenate thecake](https://reader035.vdocuments.us/reader035/viewer/2022062423/56649d625503460f94a4424f/html5/thumbnails/13.jpg)
NLE14
Basic types of phrases
Sentences Noun Phrases Verb phrases Prepositional phrases
![Page 14: 1 CONTEXT-FREE GRAMMARS. NLE 2 Syntactic analysis (Parsing) S NPVP ATNNSVBD NP AT NNthechildrenate thecake](https://reader035.vdocuments.us/reader035/viewer/2022062423/56649d625503460f94a4424f/html5/thumbnails/14.jpg)
NLE15
Basic types of sentences
![Page 15: 1 CONTEXT-FREE GRAMMARS. NLE 2 Syntactic analysis (Parsing) S NPVP ATNNSVBD NP AT NNthechildrenate thecake](https://reader035.vdocuments.us/reader035/viewer/2022062423/56649d625503460f94a4424f/html5/thumbnails/15.jpg)
NLE16
Noun phases: premodifiers
NP (Det) (Card) (Ord) (Quant) (AP) Nominal Det: Determiners
– a flight– Optional: I’m looking for flights to Denver
Card: Cardinal numbers (one stop) Ord: Ordinal numbers (the first flight) Quantifiers: most flights to Denver leave in the morning AP (Adjectives): three very expensive seats
![Page 16: 1 CONTEXT-FREE GRAMMARS. NLE 2 Syntactic analysis (Parsing) S NPVP ATNNSVBD NP AT NNthechildrenate thecake](https://reader035.vdocuments.us/reader035/viewer/2022062423/56649d625503460f94a4424f/html5/thumbnails/16.jpg)
NLE17
Noun phases: postmodifiers
Nominal Noun Nominal Nominal PP (PP) (PP) Nominal Nominal GerundVP Nominal Nominal RelClause
![Page 17: 1 CONTEXT-FREE GRAMMARS. NLE 2 Syntactic analysis (Parsing) S NPVP ATNNSVBD NP AT NNthechildrenate thecake](https://reader035.vdocuments.us/reader035/viewer/2022062423/56649d625503460f94a4424f/html5/thumbnails/17.jpg)
NLE18
Types of postnominal modifiers
![Page 18: 1 CONTEXT-FREE GRAMMARS. NLE 2 Syntactic analysis (Parsing) S NPVP ATNNSVBD NP AT NNthechildrenate thecake](https://reader035.vdocuments.us/reader035/viewer/2022062423/56649d625503460f94a4424f/html5/thumbnails/18.jpg)
NLE19
Recursion
Nominal Nominal PP (PP) (PP)– Is an example of RECURSIVE rule
Other examples:– NP NP PP– VP VP PP
Recursion a powerful device, but could have bad consequences (see lectures on parsing)
![Page 19: 1 CONTEXT-FREE GRAMMARS. NLE 2 Syntactic analysis (Parsing) S NPVP ATNNSVBD NP AT NNthechildrenate thecake](https://reader035.vdocuments.us/reader035/viewer/2022062423/56649d625503460f94a4424f/html5/thumbnails/19.jpg)
NLE20
Recursion and VP attachment
![Page 20: 1 CONTEXT-FREE GRAMMARS. NLE 2 Syntactic analysis (Parsing) S NPVP ATNNSVBD NP AT NNthechildrenate thecake](https://reader035.vdocuments.us/reader035/viewer/2022062423/56649d625503460f94a4424f/html5/thumbnails/20.jpg)
NLE21
Coordination
NP NP and NP– John and Mary left
VP VP and VP– John talks softly and carries a big stick
S S and / but / S– Kim is a lawyer but Sandy is reading medicine.
In fact, probably English has a– XP XP and XP
rule
![Page 21: 1 CONTEXT-FREE GRAMMARS. NLE 2 Syntactic analysis (Parsing) S NPVP ATNNSVBD NP AT NNthechildrenate thecake](https://reader035.vdocuments.us/reader035/viewer/2022062423/56649d625503460f94a4424f/html5/thumbnails/21.jpg)
NLE22
Agreement
This dog Those dogs *This dogs *Those dogs This dog is smart *This dog are smart *Those dogs is smart
![Page 22: 1 CONTEXT-FREE GRAMMARS. NLE 2 Syntactic analysis (Parsing) S NPVP ATNNSVBD NP AT NNthechildrenate thecake](https://reader035.vdocuments.us/reader035/viewer/2022062423/56649d625503460f94a4424f/html5/thumbnails/22.jpg)
NLE24
CFGs vs Regular languages
For many applications, finite state languages (the languages defined by FA) are appropriate
Limitation of FAs: cannot count– I.e., cannot check A n B n
Example of construction showing that English is CF: long-distance dependencies– Which film did Kim say the director who we just met
_ recommended _?
![Page 23: 1 CONTEXT-FREE GRAMMARS. NLE 2 Syntactic analysis (Parsing) S NPVP ATNNSVBD NP AT NNthechildrenate thecake](https://reader035.vdocuments.us/reader035/viewer/2022062423/56649d625503460f94a4424f/html5/thumbnails/23.jpg)
NLE25
The Chomsky Hierarchy
Finite-state languages (type 3)– A bC | Cb (a single NT on the right)
Context-free languages (type 2)– A BB
Context-sensitive languages (type 1)– CAC BB
Recursively enumerable languages– Every language that can be specified by a finite algorithm
![Page 24: 1 CONTEXT-FREE GRAMMARS. NLE 2 Syntactic analysis (Parsing) S NPVP ATNNSVBD NP AT NNthechildrenate thecake](https://reader035.vdocuments.us/reader035/viewer/2022062423/56649d625503460f94a4424f/html5/thumbnails/24.jpg)
NLE26
Readings
Jurafsky and Martin, chapter 9 The chapters on context-free languages in
– The Free Dictionary: http://encyclopedia.thefreedictionary.com/Context-free%20language
– Wikipedia: http://en.wikipedia.org/wiki/Context-free_grammar