LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 9: 9/25.

Slides:



Advertisements
Similar presentations
November 2008NLP1 Natural Language Processing Definite Clause Grammars.
Advertisements

CSA4050: Advanced Topics in NLP Semantics IV Partial Execution Proper Noun Adjective.
LING 388: Language and Computers Sandiway Fong Lecture 15: 10/18.
LING 388: Language and Computers Sandiway Fong Lecture 9: 9/27.
LING 388: Language and Computers Sandiway Fong 9/29 Lecture 11.
LING 388: Language and Computers Sandiway Fong Lecture 24: 11/16.
LING 388: Language and Computers Sandiway Fong Lecture 16: 10/20.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 8: 9/29.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 7: 9/12.
LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 10: 9/27.
LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 12: 10/4.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 9: 9/21.
LING 388: Language and Computers Sandiway Fong Lecture 15: 10/17.
LING 388: Language and Computers Sandiway Fong Lecture 21: 11/7.
LING 388: Language and Computers Sandiway Fong Lecture 12: 10/5.
LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 8: 9/18.
LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 7: 9/11.
LING 388 Language and Computers Lecture 8 9/25/03 Sandiway FONG.
LING 388: Language and Computers Sandiway Fong Lecture 28: 12/6.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 22: 11/15.
LING 388: Language and Computers Sandiway Fong Lecture 20: 11/2.
LING 388: Language and Computers Sandiway Fong Lecture 14: 10/13.
LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 6: 9/6.
LING 388: Language and Computers Sandiway Fong Lecture 6: 9/13.
LING 388: Language and Computers Sandiway Fong Lecture 11: 10/3.
LING 388 Language and Computers Lecture 10 10/2/03 Sandiway FONG.
LING 388 Language and Computers Take-Home Final Examination 12/9/03 Sandiway FONG.
LING 388: Language and Computers Sandiway Fong Lecture 28: 12/5.
LING 388 Language and Computers Lecture 20 11/6/03 Sandiway FONG.
LING 388 Language and Computers Lecture 18 10/30/03 Sandiway FONG.
LING 388: Language and Computers Sandiway Fong Lecture 17: 10/25.
LING 388: Language and Computers Sandiway Fong Lecture 10: 9/26.
LING 388 Language and Computers Lecture 7 9/23/03 Sandiway FONG.
LING 388: Language and Computers Sandiway Fong Lecture 16: 10/19.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 5: 9/5.
LING 388 Language and Computers Lecture 9 9/30/03 Sandiway FONG.
LING 388 Language and Computers Lecture 13 10/14/03 Sandiway FONG.
LING 388: Language and Computers Sandiway Fong Lecture 17: 10/24.
LING 388: Language and Computers Sandiway Fong Lecture 13: 10/10.
LING 388: Language and Computers Sandiway Fong Lecture 19: 11/1.
LING 388 Language and Computers Lecture 12 10/9/03 Sandiway FONG.
LING 388 Language and Computers Lecture 6 9/18/03 Sandiway FONG.
LING 388: Language and Computers Sandiway Fong 10/4 Lecture 12.
LING/C SC/PSYC 438/538 Lecture 19 Sandiway Fong 1.
LING 388: Language and Computers Sandiway Fong Lecture 14 10/11.
LING 388: Language and Computers Sandiway Fong Lecture 17.
LING 388: Language and Computers Sandiway Fong Lecture 7.
LING/C SC/PSYC 438/538 Lecture 14 Sandiway Fong. Administrivia Midterm – This Wednesday – A bit like doing a homework in real time – Bring your laptop.
LING 388: Language and Computers Sandiway Fong Lecture 15 10/13.
LING 388: Language and Computers Sandiway Fong Lecture 30 12/8.
LING 388: Language and Computers Sandiway Fong Lecture 18.
LING 388: Language and Computers Sandiway Fong Lecture 10.
LING/C SC/PSYC 438/538 Lecture 12 10/4 Sandiway Fong.
LING 388: Language and Computers Sandiway Fong Lecture 11: 10/4.
LING 388: Language and Computers Sandiway Fong 9/27 Lecture 10.
LING/C SC/PSYC 438/538 Lecture 13 Sandiway Fong. Administrivia Reading Homework – Chapter 3 of JM: Words and Transducers.
LING/C SC/PSYC 438/538 Lecture 15 Sandiway Fong. Did you install SWI Prolog?
LING/C SC/PSYC 438/538 Lecture 20 Sandiway Fong 1.
LING 388: Language and Computers Sandiway Fong Lecture 16.
LING/C SC/PSYC 438/538 Lecture 18 Sandiway Fong. Adminstrivia Homework 7 out today – due Saturday by midnight.
CSC312 Automata Theory Lecture # 26 Chapter # 12 by Cohen Context Free Grammars.
LING/C SC/PSYC 438/538 Lecture 16 Sandiway Fong. SWI Prolog Grammar rules are translated when the program is loaded into Prolog rules. Solves the mystery.
LING/C SC/PSYC 438/538 Lecture 19 Sandiway Fong 1.
CSE 311 Foundations of Computing I Lecture 19 Recursive Definitions: Context-Free Grammars and Languages Spring
LING/C SC/PSYC 438/538 Lecture 17 Sandiway Fong. Last Time Talked about: – 1. Declarative (logical) reading of grammar rules – 2. Prolog query: s(String,[]).
LING/C SC/PSYC 438/538 Lecture 21 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 21 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 22 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 24 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 26 Sandiway Fong.
Presentation transcript:

LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 9: 9/25

Administrivia Reminder –Homework 2 due today –to be reviewed in class on Thursday

Administrivia Last Thursday: –class replaced by talk on Treebank experiments –we’ll come back to statistical parsing later in the course parse input.lisp input.lisp.parsed wsj obj.gz

Regular Grammars: Recap Given right recursive regular grammar s --> [b], ays. ays --> [a], a. a --> [a], exclam. a --> [a], a. exclam --> [!]. Try ?- s(L,[]). –Prolog returns one answer and waits for action (type ; to get the next, to finish) Output: ?- s(L,[]). L = [b,a,a,!] ? ; L = [b,a,a,a,!] ? ; L = [b,a,a,a,a,!] ? ; L = [b,a,a,a,a,a,!] ? ; L = [b,a,a,a,a,a,a,!] ? ; L = [b,a,a,a,a,a,a,a,!] ? ; L = [b,a,a,a,a,a,a,a,a,!] ? Prolog is enumerating the strings of the language

Regular Grammars: Recap left recursive regular grammar: s --> a, [!]. a --> firsta, [a]. a --> a, [a]. firsta --> b, [a]. b --> [b]. also works as an enumerator but not so well as a decider Example: ?- s(L,[]). –vs ?- s([b,a,!],[]). Computational behavior –have to be aware of Prolog’s computation rule: –top-down, depth-first, left- to-right

Regular Grammars: Recap Beyond regular grammars –a n b n = {ab, aabb, aaabbb, aaaabbbb,... } n≥ 1 is not a regular language A regular grammar extended to allow both left and right recursive rules can accept/generate it 1.a --> [a], b. 2.b --> [b]. 3.b --> a, [b]. B A b a A B A b a Elementary trees generated by rules generated by rules (center-embedding recursive tree)

DCG extra parameter –used for generating a parse tree –feature agreement e.g. English determiner-noun agreement extra parameter –allows counting

Extra Argument and Agreement Idea: –We can also use an extra argument to impose constraints between constituents within a DCG rule –(in fact, we can have multiple extra arguments) Example: –English determiner-noun number agreement –Data: the man the men a man *a men –Lexical Features: man singular men plural

Extra Argument and Agreement Data: –the man/men –a man/*a men Grammar: s(s(Y,Z)) --> np(Y), vp(Z). np(np(Y)) --> pronoun(Y). pronoun(i) --> [i]. pronoun(we) --> [we]. np(np(D,N)) --> det(D), common_noun(N). det(det(the)) --> [the]. det(det(a)) --> [a]. common_noun(n(ball)) --> [ball]. common_noun(n(man)) --> [man]. common_noun(n(men)) --> [men]. Grammar contd. vp(vp(Y)) --> unergative(Y). vp(vp(Y,Z)) --> transitive(Y), np(Z). unergative(v(ran)) --> [ran]. transitive(v(hit)) --> [hit].

Extra Argument and Agreement Let’s test and modify this grammar in Prolog Test: ?- s(Tree,Sentence,[]). Sentence is a Prolog list to be supplied by user Tree a variable

Extra Argument and Agreement Data: –the man/men –a man/*a men Grammar: (NP section) –np(np(Y)) --> pronoun(Y). –np(np(D,N)) --> det(D), common_noun(N,Number). –det(det(the)) --> [the]. –det(det(a)) --> [a]. –common_noun(n(ball),sg) --> [ball]. –common_noun(n(man),sg) --> [man]. –common_noun(n(men),pl) --> [men]. –pronoun(i) --> [i]. –pronoun(we) --> [we]. –Idea: specify singular ( sg ) and plural ( pl ) for common nouns using an extra argument Rules the can combine with singular or plural nouns a can combine only with singular nouns

Extra Argument and Agreement Data: –the man/men –a man/*a men Grammar: (NP section) np(np(Y)) --> pronoun(Y). np(np(D,N)) --> det(D,Number), common_noun(N,Number). det(det(the),sg) --> [the]. det(det(the),pl) --> [the]. det(det(a),sg) --> [a]. common_noun(n(ball),sg) --> [ball]. common_noun(n(man),sg) --> [man]. common_noun(n(men),pl) --> [men]. pronoun(i) --> [i]. pronoun(we) --> [we]. –Idea: give determiners a number feature as well and make it agree with the noun Rules the can combine with singular or plural nouns a can combine only with singular nouns

Extra Argument and Agreement Simplifying the grammar: det(det(the),sg) --> [the]. det(det(the),pl) --> [the]. det(det(a),sg) --> [a]. Grammar is ambiguous: –two rules for determiner the Agreement Rule (revisited): the can combine with singular or plural nouns i.e. the doesn’t care about the number of the noun DCG Rule: np(np(D,N)) --> det(D,Number), common_noun(N,Number). det(det(the),_) --> [the]. Note: _ is a variable used underscore character because we don’t care about the name of the variable

Extra Argument and Agreement Note: Use of the extra argument for agreement here is basically “syntactic sugar” and lends no more extra expressive power to the grammar rule system i.e. we can enforce the agreement without the use of the extra argument at the cost of more rules Instead of np(np(D,N)) --> det(D,Number), common_noun(N,Number). we can write: np(np(D,N)) --> detsg(D), common_nounsg(N). np(np(D,N)) --> detpl(D), common_nounpl(N). detsg(det(a)) --> [a]. detsg(det(the)) --> [the]. detpl(det(the)) --> [the]. common_nounsg(n(ball)) --> [ball]. common_nounsg(n(man)) -->[man]. common_nounpl(n(men)) --> [men].

Expressive Power and Extra Arguments General Question: –Does the extra argument change the system? –i.e. does it offer the grammar more expressive power ? Answer: –Yes Example: –We can write an otherwise regular-looking DCG for the non- regular language L ab = { a n b n | n ≥ 1 } (which cannot be encoded by any regular grammar)

Expressive Power and Extra Arguments s(X) --> [a],b(a(X)). b(X) --> [a],b(a(X)). b(a(X)) --> [b],c(X). b(a(0)) --> [b]. c(a(X)) --> [b],c(X). c(a(0)) --> [b]. Query: ?- s(0,L,[]). s --> [a],b. b --> [a],b. b --> [b],c. b --> [b]. c --> [b],c. c --> [b].  a+b+a+b+ a regular grammar regular grammar + extra argument

Expressive Power and Extra Arguments Computation tree: –?- s(0,[a,a,b,b],[]). –?- b(a(0),[a,b,b],[]). –?- b(a(a(0)),[b,b],[]). –?- c(a(0),[b],[]). –Yes s(X) --> [a],b(a(X)). b(X) --> [a],b(a(X)). b(a(X)) --> [b],c(X). b(a(0)) --> [b]. c(a(X)) --> [b],c(X). c(a(0)) --> [b].

Class Exercise Implement Case = {nom,acc} feature agreement for subject and object positions in the example grammar Examples: –*the man hit I –the man hit me