intro to grammar - university of california,...
TRANSCRIPT
![Page 1: Intro to Grammar - University of California, Berkeleyinst.cs.berkeley.edu/~cs182/sp07/notes/lecture23.gr1.pdf · systems–particularly syntax and morphology–to communicate](https://reader033.vdocuments.mx/reader033/viewer/2022052711/5abd001c7f8b9a24028e7da4/html5/thumbnails/1.jpg)
Intro to Grammar(from an NTL Perspective)
John Bryant
International Computer Science Institute
UC Berkeley
Intro to Grammar – p.1/33
![Page 2: Intro to Grammar - University of California, Berkeleyinst.cs.berkeley.edu/~cs182/sp07/notes/lecture23.gr1.pdf · systems–particularly syntax and morphology–to communicate](https://reader033.vdocuments.mx/reader033/viewer/2022052711/5abd001c7f8b9a24028e7da4/html5/thumbnails/2.jpg)
What is a grammar?• Grammar is the system of a language... It’s important to think of grammar as
something that can help you, like a friend.
• Grammar tells the users of a language what choices are possible for the word order ofany sentence to allow that sentence to be clear and sensible - that is, to beunambiguous.
• ..."prescriptive grammar," a set of "rules" governing the choice of who and whom, theuse of ain’t, and other such matters. Promoted by Jonathan Swift and other literaryfigures of the 18th century, this approach to language prescribes the "correct" way touse language.
• ..."descriptive grammar," which is the study of the ways humans usesystems–particularly syntax and morphology–to communicatethrough language.
• Therefore grammar acts as his tool to create meaning.
From google
Intro to Grammar – p.2/33
![Page 3: Intro to Grammar - University of California, Berkeleyinst.cs.berkeley.edu/~cs182/sp07/notes/lecture23.gr1.pdf · systems–particularly syntax and morphology–to communicate](https://reader033.vdocuments.mx/reader033/viewer/2022052711/5abd001c7f8b9a24028e7da4/html5/thumbnails/3.jpg)
What is an utterance?• Form• Sound
• Text
• Sign and Gesture
• And their order
• Meaning• Who doing what to whom (usually more explicit)
• Pragmatic (usually more implicit)
• Context• Shared world state
• Discourse
• Ontological knowledge
how do all these pieces fit together? Intro to Grammar – p.3/33
![Page 4: Intro to Grammar - University of California, Berkeleyinst.cs.berkeley.edu/~cs182/sp07/notes/lecture23.gr1.pdf · systems–particularly syntax and morphology–to communicate](https://reader033.vdocuments.mx/reader033/viewer/2022052711/5abd001c7f8b9a24028e7da4/html5/thumbnails/4.jpg)
Grammar is relational knowledge
Intro to Grammar – p.4/33
![Page 5: Intro to Grammar - University of California, Berkeleyinst.cs.berkeley.edu/~cs182/sp07/notes/lecture23.gr1.pdf · systems–particularly syntax and morphology–to communicate](https://reader033.vdocuments.mx/reader033/viewer/2022052711/5abd001c7f8b9a24028e7da4/html5/thumbnails/5.jpg)
Embodied Semantics• Image schemas• Force dynamic schemas• Frames• Metaphors
All these things are bound up and sent to simulation.
Intro to Grammar – p.5/33
![Page 6: Intro to Grammar - University of California, Berkeleyinst.cs.berkeley.edu/~cs182/sp07/notes/lecture23.gr1.pdf · systems–particularly syntax and morphology–to communicate](https://reader033.vdocuments.mx/reader033/viewer/2022052711/5abd001c7f8b9a24028e7da4/html5/thumbnails/6.jpg)
Syntax in one slideForm relations within a sentence, not within a word.• Word order• Constituency (grouping and labeling)• Where constituents can appear• Grammatical relations (subj, obj)• Verb subcategorization• Agreement (number, person, case, gender)
We play the game. Bill frisbee throws purple the
You am the best! They hits he.
Bob gave Anne a book. Anne gave Bob a book.
Tom walked into the cafe. Tom tumbled into the cafe the ball.
I slept the ball into the basket. She sneezed the foam off the latte.
This is the man I handed the book This is the book I handed the man
Intro to Grammar – p.6/33
![Page 7: Intro to Grammar - University of California, Berkeleyinst.cs.berkeley.edu/~cs182/sp07/notes/lecture23.gr1.pdf · systems–particularly syntax and morphology–to communicate](https://reader033.vdocuments.mx/reader033/viewer/2022052711/5abd001c7f8b9a24028e7da4/html5/thumbnails/7.jpg)
Formal grammars!We can:• Compactly encode a possibly infinite set of sentences.• Generate a string (sentence) of the language• Parse (recognize) a string• Compare the sentences that two grammars can
generate.• Implement stuff• Make clear, testable predictions about language
1. S → b S2. S → b
Intro to Grammar – p.7/33
![Page 8: Intro to Grammar - University of California, Berkeleyinst.cs.berkeley.edu/~cs182/sp07/notes/lecture23.gr1.pdf · systems–particularly syntax and morphology–to communicate](https://reader033.vdocuments.mx/reader033/viewer/2022052711/5abd001c7f8b9a24028e7da4/html5/thumbnails/8.jpg)
Parsing a sentence1. Take an input sentence and a grammar
2. Process the sentence: Top down vs bottom up search
3. Output a trace (parse tree)
1. S → b S2. S → b
Intro to Grammar – p.8/33
![Page 9: Intro to Grammar - University of California, Berkeleyinst.cs.berkeley.edu/~cs182/sp07/notes/lecture23.gr1.pdf · systems–particularly syntax and morphology–to communicate](https://reader033.vdocuments.mx/reader033/viewer/2022052711/5abd001c7f8b9a24028e7da4/html5/thumbnails/9.jpg)
Formal theories of grammar• Finite state grammar• Context free grammar• Transformational Grammar, Minimalism, X bar...• Unification grammar (GPSG, LFG, HPSG)• Construction grammar (CxG)• Embodied Construction Grammar (ECG)
Different assumptions about language and
different processing complexity.
Intro to Grammar – p.9/33
![Page 10: Intro to Grammar - University of California, Berkeleyinst.cs.berkeley.edu/~cs182/sp07/notes/lecture23.gr1.pdf · systems–particularly syntax and morphology–to communicate](https://reader033.vdocuments.mx/reader033/viewer/2022052711/5abd001c7f8b9a24028e7da4/html5/thumbnails/10.jpg)
Context free grammarsA CFG (PSG) is:• A set of terminals ⊂ Symbols
• A set nonterminals ⊂ Symbols
• A set of productions of the formNT → Symbol∗
• A designated start symbol
A tiny example CFG:• Terminals: {“(“ , “)”}• Nonterminals: {S}• Start symbol = S• Rules: {S→ “(” S “)”; S→ “(“ “)”; }
Intro to Grammar – p.10/33
![Page 11: Intro to Grammar - University of California, Berkeleyinst.cs.berkeley.edu/~cs182/sp07/notes/lecture23.gr1.pdf · systems–particularly syntax and morphology–to communicate](https://reader033.vdocuments.mx/reader033/viewer/2022052711/5abd001c7f8b9a24028e7da4/html5/thumbnails/11.jpg)
English lexicon fragment
Noun → soul | pipe | fiddlers | bowl
ProperNoun → King Cole
Pronoun → he | they | I
Verb → was | called | plays | play | slept
Adjective → old | merry | three
Article → a | the
Conjunction → and
Intro to Grammar – p.11/33
![Page 12: Intro to Grammar - University of California, Berkeleyinst.cs.berkeley.edu/~cs182/sp07/notes/lecture23.gr1.pdf · systems–particularly syntax and morphology–to communicate](https://reader033.vdocuments.mx/reader033/viewer/2022052711/5abd001c7f8b9a24028e7da4/html5/thumbnails/12.jpg)
English grammar fragment
S → NP VP
| S Conjunction S
NP → Adjective ProperNoun
| Possessive Adjective Noun
| Article Adjective* Noun
| Pronoun
VP → Verb NP
| Verb PP
PP → Preposition NP
Intro to Grammar – p.12/33
![Page 13: Intro to Grammar - University of California, Berkeleyinst.cs.berkeley.edu/~cs182/sp07/notes/lecture23.gr1.pdf · systems–particularly syntax and morphology–to communicate](https://reader033.vdocuments.mx/reader033/viewer/2022052711/5abd001c7f8b9a24028e7da4/html5/thumbnails/13.jpg)
An example parse
Intro to Grammar – p.13/33
![Page 14: Intro to Grammar - University of California, Berkeleyinst.cs.berkeley.edu/~cs182/sp07/notes/lecture23.gr1.pdf · systems–particularly syntax and morphology–to communicate](https://reader033.vdocuments.mx/reader033/viewer/2022052711/5abd001c7f8b9a24028e7da4/html5/thumbnails/14.jpg)
CFG pros and cons
Intro to Grammar – p.14/33
![Page 15: Intro to Grammar - University of California, Berkeleyinst.cs.berkeley.edu/~cs182/sp07/notes/lecture23.gr1.pdf · systems–particularly syntax and morphology–to communicate](https://reader033.vdocuments.mx/reader033/viewer/2022052711/5abd001c7f8b9a24028e7da4/html5/thumbnails/15.jpg)
CFG pros and consPROS:• Simple
• Fast
• Pretty good with word order and constituency
CONS:• Hard to prevent overgeneration
• No semantics
• Too simple?
Intro to Grammar – p.15/33
![Page 16: Intro to Grammar - University of California, Berkeleyinst.cs.berkeley.edu/~cs182/sp07/notes/lecture23.gr1.pdf · systems–particularly syntax and morphology–to communicate](https://reader033.vdocuments.mx/reader033/viewer/2022052711/5abd001c7f8b9a24028e7da4/html5/thumbnails/16.jpg)
Generated sentencesGoodies:• Old Kind Cole was a merry old soul• A merry old soul was he• He called for his pipe• He called for his bowl• He called for his three fiddlers
Baddies:• The fiddlers plays for old King Cole• He slept the fiddlers• Old King Cole called for he
Intro to Grammar – p.16/33
![Page 17: Intro to Grammar - University of California, Berkeleyinst.cs.berkeley.edu/~cs182/sp07/notes/lecture23.gr1.pdf · systems–particularly syntax and morphology–to communicate](https://reader033.vdocuments.mx/reader033/viewer/2022052711/5abd001c7f8b9a24028e7da4/html5/thumbnails/17.jpg)
Context free assumption
Verb→ was | called | plays | play | slept how do we fix this?
Intro to Grammar – p.17/33
![Page 18: Intro to Grammar - University of California, Berkeleyinst.cs.berkeley.edu/~cs182/sp07/notes/lecture23.gr1.pdf · systems–particularly syntax and morphology–to communicate](https://reader033.vdocuments.mx/reader033/viewer/2022052711/5abd001c7f8b9a24028e7da4/html5/thumbnails/18.jpg)
Updating the lexicon
SgNoun → soul | pipe | bowl
PlNoun → fiddlers
SgProperNoun → King Cole
3rdSgPronoun → he
3rdPlPronoun → they
3rdPlPronoun → I
SgArticle → a | the
PlArticle → the
1stSgIntrans → sleep
3rdSgIntrans → sleeps
3rdPlIntrans → sleep
1stSgTrans → play
3rdSgTrans → plays
3rdPlTrans → play
Intro to Grammar – p.18/33
![Page 19: Intro to Grammar - University of California, Berkeleyinst.cs.berkeley.edu/~cs182/sp07/notes/lecture23.gr1.pdf · systems–particularly syntax and morphology–to communicate](https://reader033.vdocuments.mx/reader033/viewer/2022052711/5abd001c7f8b9a24028e7da4/html5/thumbnails/19.jpg)
Updating the syntactic rulesOriginal:
NP → Adjective ProperNoun
| Possessive Adjective Noun
| Article Adjective* Noun
| Pronoun
Updated:
3rdSgNP → Adjective SgProperNoun
| Possessive Adjective SgNoun
| SgArticle Adjective* SgNoun
| 3rdSgPronoun
elegant?
Intro to Grammar – p.19/33
![Page 20: Intro to Grammar - University of California, Berkeleyinst.cs.berkeley.edu/~cs182/sp07/notes/lecture23.gr1.pdf · systems–particularly syntax and morphology–to communicate](https://reader033.vdocuments.mx/reader033/viewer/2022052711/5abd001c7f8b9a24028e7da4/html5/thumbnails/20.jpg)
Unification grammar
Pronoun → Inum = SGperson = 1
I (type)num : sgperson : 1
CFG rules are augmented with constraints and
their instances are augmented with feature structures.
Intro to Grammar – p.20/33
![Page 21: Intro to Grammar - University of California, Berkeleyinst.cs.berkeley.edu/~cs182/sp07/notes/lecture23.gr1.pdf · systems–particularly syntax and morphology–to communicate](https://reader033.vdocuments.mx/reader033/viewer/2022052711/5abd001c7f8b9a24028e7da4/html5/thumbnails/21.jpg)
Complex feature structures
NP → Article Nounself.agreement = Noun.agreementNoun.agreement = Article.agreement
NP
agreement : 1
Agreement
num : sg
person : 1
Article :
[
agreement : 1
]
Noun :
[
agreement : 1
]
unification/coindexation
Intro to Grammar – p.21/33
![Page 22: Intro to Grammar - University of California, Berkeleyinst.cs.berkeley.edu/~cs182/sp07/notes/lecture23.gr1.pdf · systems–particularly syntax and morphology–to communicate](https://reader033.vdocuments.mx/reader033/viewer/2022052711/5abd001c7f8b9a24028e7da4/html5/thumbnails/22.jpg)
Feature structure unificationA simple recursive algorithm that checks to see if twofeature structures are compatible.
• Base case: if two atomic values are the same, then theyunify
• Recursive case: if two feature structures have featuresthat unify, then the two feature structures unify.
• Otherwise, return failure
Intro to Grammar – p.22/33
![Page 23: Intro to Grammar - University of California, Berkeleyinst.cs.berkeley.edu/~cs182/sp07/notes/lecture23.gr1.pdf · systems–particularly syntax and morphology–to communicate](https://reader033.vdocuments.mx/reader033/viewer/2022052711/5abd001c7f8b9a24028e7da4/html5/thumbnails/23.jpg)
Unification success
agreement : 1
[
person : 3
]
subject :
[
case : nom
agreement : 1
]
unified with
subject :
case :
agreement :
[
person : 3
number : SG
]
=
agreement : 1
subject :
case : nom
agreement : 1
[
person : 3
number : SG
]
Intro to Grammar – p.23/33
![Page 24: Intro to Grammar - University of California, Berkeleyinst.cs.berkeley.edu/~cs182/sp07/notes/lecture23.gr1.pdf · systems–particularly syntax and morphology–to communicate](https://reader033.vdocuments.mx/reader033/viewer/2022052711/5abd001c7f8b9a24028e7da4/html5/thumbnails/24.jpg)
Unification failure
agreement : 1
subject :
[
case : nom
agreement : 1
]
unified with
subject :
case :
agreement :
[
person : 3
number : SG
]
=
FAILURE
Intro to Grammar – p.24/33
![Page 25: Intro to Grammar - University of California, Berkeleyinst.cs.berkeley.edu/~cs182/sp07/notes/lecture23.gr1.pdf · systems–particularly syntax and morphology–to communicate](https://reader033.vdocuments.mx/reader033/viewer/2022052711/5abd001c7f8b9a24028e7da4/html5/thumbnails/25.jpg)
What are we missing?Still no semantics!
Intro to Grammar – p.25/33
![Page 26: Intro to Grammar - University of California, Berkeleyinst.cs.berkeley.edu/~cs182/sp07/notes/lecture23.gr1.pdf · systems–particularly syntax and morphology–to communicate](https://reader033.vdocuments.mx/reader033/viewer/2022052711/5abd001c7f8b9a24028e7da4/html5/thumbnails/26.jpg)
Construction grammar• Grammaticality = form and function• Each rule (construction) is a set of form/meaning
constraints (a pair)• Not purely compositional• Implies early use of semantics in processing
"basket"Form
"into"
Meaning
container
Intro to Grammar – p.26/33
![Page 27: Intro to Grammar - University of California, Berkeleyinst.cs.berkeley.edu/~cs182/sp07/notes/lecture23.gr1.pdf · systems–particularly syntax and morphology–to communicate](https://reader033.vdocuments.mx/reader033/viewer/2022052711/5abd001c7f8b9a24028e7da4/html5/thumbnails/27.jpg)
Example Constructions• “-ed”↔ past speech time, completed action• “give”↔ a give action• NP0 V NP1 NP2 ↔ Transfer Scene + bindings
(Goldberg)• WXDY↔ How come X is doing Y? (Kay, Fillmore)• The There Constructions (Lakoff)
Each has a form pole and a meaning pole.
Intro to Grammar – p.27/33
![Page 28: Intro to Grammar - University of California, Berkeleyinst.cs.berkeley.edu/~cs182/sp07/notes/lecture23.gr1.pdf · systems–particularly syntax and morphology–to communicate](https://reader033.vdocuments.mx/reader033/viewer/2022052711/5abd001c7f8b9a24028e7da4/html5/thumbnails/28.jpg)
ECG overview• Embodied + Construction Grammar• Precise, unification based (LFG, HPSG, CxG)• Simulation• Primitives: schemas and constructions• Schemas and constructions form inheritance
hierarchies.
Intro to Grammar – p.28/33
![Page 29: Intro to Grammar - University of California, Berkeleyinst.cs.berkeley.edu/~cs182/sp07/notes/lecture23.gr1.pdf · systems–particularly syntax and morphology–to communicate](https://reader033.vdocuments.mx/reader033/viewer/2022052711/5abd001c7f8b9a24028e7da4/html5/thumbnails/29.jpg)
Embodied schemas in ECG
schema TLtrajectorlandmark
schema SPGsubcase of TLsourcepathgoal
schema Containerinteriorexteriorboundaryportal
Intro to Grammar – p.29/33
![Page 30: Intro to Grammar - University of California, Berkeleyinst.cs.berkeley.edu/~cs182/sp07/notes/lecture23.gr1.pdf · systems–particularly syntax and morphology–to communicate](https://reader033.vdocuments.mx/reader033/viewer/2022052711/5abd001c7f8b9a24028e7da4/html5/thumbnails/30.jpg)
Actions
schema ForceApplicationActionsubcase of Actionevokes ForceTransfer as forceTransferroles
actor (inherited)actedUpon
constraintsactor←→ forceTransfer.supplieractedUpon←→ forceTransfer.recipient
ECG’s KR tools: subcase of, roles, evokes, constraints
Intro to Grammar – p.30/33
![Page 31: Intro to Grammar - University of California, Berkeleyinst.cs.berkeley.edu/~cs182/sp07/notes/lecture23.gr1.pdf · systems–particularly syntax and morphology–to communicate](https://reader033.vdocuments.mx/reader033/viewer/2022052711/5abd001c7f8b9a24028e7da4/html5/thumbnails/31.jpg)
An Into construction
construction Intosubcase of DynamicSpatialPrepform : “into”meaning : SPG
evokes Container as cself m.goal←→ c.interiorself m.source←→ c.exteriorself m.landmark←→ c
Intro to Grammar – p.31/33
![Page 32: Intro to Grammar - University of California, Berkeleyinst.cs.berkeley.edu/~cs182/sp07/notes/lecture23.gr1.pdf · systems–particularly syntax and morphology–to communicate](https://reader033.vdocuments.mx/reader033/viewer/2022052711/5abd001c7f8b9a24028e7da4/html5/thumbnails/32.jpg)
An ActiveSelfMotion construction
construction ActiveSelfMotionsubcase of ActiveVPconstructional
constituentsv : Verbpp : SpatialPP
formvfbefore ppf
meaning : SelfMotionPathEventself m.profiled-participant←→ self m.moverself m.profiled-process←→ self m.laself m.profiled-process←→ vm
self m.spg←→ ppm
Intro to Grammar – p.32/33
![Page 33: Intro to Grammar - University of California, Berkeleyinst.cs.berkeley.edu/~cs182/sp07/notes/lecture23.gr1.pdf · systems–particularly syntax and morphology–to communicate](https://reader033.vdocuments.mx/reader033/viewer/2022052711/5abd001c7f8b9a24028e7da4/html5/thumbnails/33.jpg)
What’s neural about all this?Nothing inherently, but if you use it right, plenty:• Embodied schemas with neurally plausible reductions• Feature structures and bindings are neurally reducible• Simulation/X-schemas• Probabilistic ECG
Intro to Grammar – p.33/33