review of homework 4 november 20, 2003. exercise 1 (a) 1 pt modify the dcg to accept the omission of...
TRANSCRIPT
![Page 1: Review of Homework 4 November 20, 2003. Exercise 1 (A) 1 pt Modify the DCG to accept the omission of the complementizer that for object relative clauses](https://reader036.vdocuments.us/reader036/viewer/2022081602/551c43f75503469d6a8b45a4/html5/thumbnails/1.jpg)
Review of Homework Review of Homework 44
Review of Homework Review of Homework 44
November 20, 2003November 20, 2003
![Page 2: Review of Homework 4 November 20, 2003. Exercise 1 (A) 1 pt Modify the DCG to accept the omission of the complementizer that for object relative clauses](https://reader036.vdocuments.us/reader036/viewer/2022081602/551c43f75503469d6a8b45a4/html5/thumbnails/2.jpg)
Exercise 1 (A) 1 pt
• Modify the DCG to accept the omission of the complementizer that for object relative clauses
• Your DCG should accept both of the following:
• the cat John saw• the cat that John saw
as NPs
![Page 3: Review of Homework 4 November 20, 2003. Exercise 1 (A) 1 pt Modify the DCG to accept the omission of the complementizer that for object relative clauses](https://reader036.vdocuments.us/reader036/viewer/2022081602/551c43f75503469d6a8b45a4/html5/thumbnails/3.jpg)
s(s(X,Y)) --> np(X), vp(Y).vp(vp(X,Y)) --> transitive_verb(X), np(Y).np(np(X)) --> proper_noun(X).
% Special rules for relative clausesnp(np(np(Y,Z),U)) --> det(Y), common_noun(Z), sbar(U).np(np(x)) --> [].sbar(lambda(x,Y)) --> complementizer, s(Y).complementizer --> [that].complementizer --> [].
% Lexicontransitive_verb(v(hit)) --> [hit].transitive_verb(v(saw)) --> [saw].transitive_verb(v(hissed_at)) --> [hissed,at].proper_noun(john) --> [john].proper_noun(mary) --> [mary].common_noun(n(man)) --> [man].common_noun(n(cat)) --> [cat].det(det(the)) --> [the].
![Page 4: Review of Homework 4 November 20, 2003. Exercise 1 (A) 1 pt Modify the DCG to accept the omission of the complementizer that for object relative clauses](https://reader036.vdocuments.us/reader036/viewer/2022081602/551c43f75503469d6a8b45a4/html5/thumbnails/4.jpg)
Exercise 1 (B) 3 pts
doubly-embedded object relative clause structure:
Mary hit [[the mani] that [[ the catj] that John saw [ej]] hissed at [ei]]object
![Page 5: Review of Homework 4 November 20, 2003. Exercise 1 (A) 1 pt Modify the DCG to accept the omission of the complementizer that for object relative clauses](https://reader036.vdocuments.us/reader036/viewer/2022081602/551c43f75503469d6a8b45a4/html5/thumbnails/5.jpg)
Exercise 1 (B) 3 pts
doubly-embedded object relative clause structure:
Mary hit [[the mani] that [[ the catj] that John saw [ej]] hissed at [ei]]object
![Page 6: Review of Homework 4 November 20, 2003. Exercise 1 (A) 1 pt Modify the DCG to accept the omission of the complementizer that for object relative clauses](https://reader036.vdocuments.us/reader036/viewer/2022081602/551c43f75503469d6a8b45a4/html5/thumbnails/6.jpg)
Exercise 1 (B) 3 pts
doubly-embedded object relative clause structure:
Mary hit [[the mani] that [[ the catj] that John saw [ej]] hissed at [ei]]
objectobject
![Page 7: Review of Homework 4 November 20, 2003. Exercise 1 (A) 1 pt Modify the DCG to accept the omission of the complementizer that for object relative clauses](https://reader036.vdocuments.us/reader036/viewer/2022081602/551c43f75503469d6a8b45a4/html5/thumbnails/7.jpg)
WithoutWithout any further modification to the D any further modification to the DCG, construct and show parses for:CG, construct and show parses for:
(i) A sentence with two levels of embe(i) A sentence with two levels of embedding using subject relative clausesdding using subject relative clauses(ii) A sentence with two levels of embe(ii) A sentence with two levels of embedding using one subject and one objecdding using one subject and one object relative clauset relative clause(iii) Any sentence with a triply-embedd(iii) Any sentence with a triply-embedded relative clause structureed relative clause structure
![Page 8: Review of Homework 4 November 20, 2003. Exercise 1 (A) 1 pt Modify the DCG to accept the omission of the complementizer that for object relative clauses](https://reader036.vdocuments.us/reader036/viewer/2022081602/551c43f75503469d6a8b45a4/html5/thumbnails/8.jpg)
(i) A sentence with two levels of (i) A sentence with two levels of embedding using embedding using subjectsubject relative clauses relative clauses
mary,saw,the,cat,that,hissed,at,the,man,that,hit,john subject subject
![Page 9: Review of Homework 4 November 20, 2003. Exercise 1 (A) 1 pt Modify the DCG to accept the omission of the complementizer that for object relative clauses](https://reader036.vdocuments.us/reader036/viewer/2022081602/551c43f75503469d6a8b45a4/html5/thumbnails/9.jpg)
(ii) A sentence with two levels of (ii) A sentence with two levels of embedding using embedding using one subjectone subject and and one one objectobject relative clause relative clause
mary,saw,the,cat,that,hissed,at,the,man,that,john,hit subject object
mary,saw,the,man,that,the,cat,that,hit,hohn,hissed,at object subject
![Page 10: Review of Homework 4 November 20, 2003. Exercise 1 (A) 1 pt Modify the DCG to accept the omission of the complementizer that for object relative clauses](https://reader036.vdocuments.us/reader036/viewer/2022081602/551c43f75503469d6a8b45a4/html5/thumbnails/10.jpg)
(iii) Any sentence with a triply-embedded (iii) Any sentence with a triply-embedded relative clause structurerelative clause structure
mary,saw,the,cat,that,hissed,at,the,man,that,hit,the,cat,that,john,saw subject subject object
![Page 11: Review of Homework 4 November 20, 2003. Exercise 1 (A) 1 pt Modify the DCG to accept the omission of the complementizer that for object relative clauses](https://reader036.vdocuments.us/reader036/viewer/2022081602/551c43f75503469d6a8b45a4/html5/thumbnails/11.jpg)
• Your sentence has to be grammatical!
![Page 12: Review of Homework 4 November 20, 2003. Exercise 1 (A) 1 pt Modify the DCG to accept the omission of the complementizer that for object relative clauses](https://reader036.vdocuments.us/reader036/viewer/2022081602/551c43f75503469d6a8b45a4/html5/thumbnails/12.jpg)
Extra Credit Homework Question3 pt
• Modify the DCG to allow that to be omitted only in the case of object relative clauses, i.e. grammar should still accept:– the cat John sawbut reject its subject relative clause counterpart:– *the cat saw John
• Hint (for one possible implementation):– Look at how subject/verb agreement was enforced
![Page 13: Review of Homework 4 November 20, 2003. Exercise 1 (A) 1 pt Modify the DCG to accept the omission of the complementizer that for object relative clauses](https://reader036.vdocuments.us/reader036/viewer/2022081602/551c43f75503469d6a8b45a4/html5/thumbnails/13.jpg)
s(s(X,Y),EC) --> np(X), vp(Y),
{(nonvar(EC), X = np(x)) -> EC == overt}.
vp(vp(X,Y)) --> transitive_verb(X), np(Y).
np(np(X)) --> proper_noun(X).
np(np(x)) --> [].
np(np(np(Y,Z),U)) --> det(Y), common_noun(Z), sbar(U).
sbar(lambda(x,Y)) --> complementizer(EC), s(Y,EC).
complementizer(overt) --> [that].
complementizer(empty) --> [].
![Page 14: Review of Homework 4 November 20, 2003. Exercise 1 (A) 1 pt Modify the DCG to accept the omission of the complementizer that for object relative clauses](https://reader036.vdocuments.us/reader036/viewer/2022081602/551c43f75503469d6a8b45a4/html5/thumbnails/14.jpg)
Exercise 2: Disjunctive Tree-Walker1 pt
• Homework Question:– Modify visit/1 to search for all NP nodes– How many times should visit/1 succeed for the
following sentence?• Mary hit the cat that hissed at John
• Hint:– You’ll need to add more than one clause to visit/1
![Page 15: Review of Homework 4 November 20, 2003. Exercise 1 (A) 1 pt Modify the DCG to accept the omission of the complementizer that for object relative clauses](https://reader036.vdocuments.us/reader036/viewer/2022081602/551c43f75503469d6a8b45a4/html5/thumbnails/15.jpg)
visit(X) :- X =.. [_,A1,_],visit(A1).visit(X) :- X =.. [_,_,A2],visit(A2).visit(X) :- X =.. [_,A],visit(A).
visit(np(_)).
visit(np(_,_)).
It succeeds 5 times, visiting each np node.
![Page 16: Review of Homework 4 November 20, 2003. Exercise 1 (A) 1 pt Modify the DCG to accept the omission of the complementizer that for object relative clauses](https://reader036.vdocuments.us/reader036/viewer/2022081602/551c43f75503469d6a8b45a4/html5/thumbnails/16.jpg)
Exercise 3: Collecting Answers1 pt
• Homework Question:– Assuming the unmodified version of visit/1– What does the query
• ?- s(X,[mary,hit,the,cat,that,hissed,at,john],[]), findall(once,visit(X),L),
length(L,N).do?
![Page 17: Review of Homework 4 November 20, 2003. Exercise 1 (A) 1 pt Modify the DCG to accept the omission of the complementizer that for object relative clauses](https://reader036.vdocuments.us/reader036/viewer/2022081602/551c43f75503469d6a8b45a4/html5/thumbnails/17.jpg)
s(X,[mary,hit,the,cat,that,hissed,at,john],[]),findall(once,visit(X),L),length(L,N).
X = s(np(mary), vp(v(hit), np(np(det(the), n(cat)), lambda(x, s(np(x), vp(v(hissed_at), np(john)))))))
L = [once, once, once, once, once, once, once, once]
N = 8
![Page 18: Review of Homework 4 November 20, 2003. Exercise 1 (A) 1 pt Modify the DCG to accept the omission of the complementizer that for object relative clauses](https://reader036.vdocuments.us/reader036/viewer/2022081602/551c43f75503469d6a8b45a4/html5/thumbnails/18.jpg)
Exercise 4: Operators and Variables
• Homework Question:– Determine the status of the following sentences
with respect to the DCG, filter1 and filter2. – Explain your answers when there is a violation.
• 1. *hit 1pt• 2. *saw the man that hit 1pt
![Page 19: Review of Homework 4 November 20, 2003. Exercise 1 (A) 1 pt Modify the DCG to accept the omission of the complementizer that for object relative clauses](https://reader036.vdocuments.us/reader036/viewer/2022081602/551c43f75503469d6a8b45a4/html5/thumbnails/19.jpg)
• Two Filters:– All variables must be bound by an operator
(x)– Operator (x) can only bind one variable
• Implementation:– filter1(X) :- \+ ( variable(X,F), var(F) ). – filter2(X) :- operator(X).
![Page 20: Review of Homework 4 November 20, 2003. Exercise 1 (A) 1 pt Modify the DCG to accept the omission of the complementizer that for object relative clauses](https://reader036.vdocuments.us/reader036/viewer/2022081602/551c43f75503469d6a8b45a4/html5/thumbnails/20.jpg)
EX4-1: *hit violates both filter 1 and 2 X = s(np(x), vp(v(hit), np(x)))
• it violates filter1 because the variables np(x) are not bound by an operator.
• it violates filter2 because there is no operator.(This shows the inadequacy of this rule because it also rules out sentences like "john saw mary".)
![Page 21: Review of Homework 4 November 20, 2003. Exercise 1 (A) 1 pt Modify the DCG to accept the omission of the complementizer that for object relative clauses](https://reader036.vdocuments.us/reader036/viewer/2022081602/551c43f75503469d6a8b45a4/html5/thumbnails/21.jpg)
EX4-2: X = s(np(x),vp(v(saw),np(np(det(the), n(man)), lambda(x,s(np(x),vp(v(hit), np(x)))))))
• it violates filter1 because the first np(x) is not bound by an operator.
• it violates filter2 because there are two variables to be bound one operator under the man.
![Page 22: Review of Homework 4 November 20, 2003. Exercise 1 (A) 1 pt Modify the DCG to accept the omission of the complementizer that for object relative clauses](https://reader036.vdocuments.us/reader036/viewer/2022081602/551c43f75503469d6a8b45a4/html5/thumbnails/22.jpg)
Big Picture
• Relative clauses:
John saw the man that the cat hissed at.
![Page 23: Review of Homework 4 November 20, 2003. Exercise 1 (A) 1 pt Modify the DCG to accept the omission of the complementizer that for object relative clauses](https://reader036.vdocuments.us/reader036/viewer/2022081602/551c43f75503469d6a8b45a4/html5/thumbnails/23.jpg)
Big Picture
• Relative clauses:
John saw the man that the cat hissed at e. np(x)
![Page 24: Review of Homework 4 November 20, 2003. Exercise 1 (A) 1 pt Modify the DCG to accept the omission of the complementizer that for object relative clauses](https://reader036.vdocuments.us/reader036/viewer/2022081602/551c43f75503469d6a8b45a4/html5/thumbnails/24.jpg)
Big Picture
• Relative clauses:
John saw the man that the cat hissed at e. np(x)
![Page 25: Review of Homework 4 November 20, 2003. Exercise 1 (A) 1 pt Modify the DCG to accept the omission of the complementizer that for object relative clauses](https://reader036.vdocuments.us/reader036/viewer/2022081602/551c43f75503469d6a8b45a4/html5/thumbnails/25.jpg)
Big Picture
• The relation between and np(x):
John saw the man that the cat hissed at e. np(x)
0
0 1
2+
0 1 1
2+
ok
* F1
* F1
* F2new
ok * F2old
![Page 26: Review of Homework 4 November 20, 2003. Exercise 1 (A) 1 pt Modify the DCG to accept the omission of the complementizer that for object relative clauses](https://reader036.vdocuments.us/reader036/viewer/2022081602/551c43f75503469d6a8b45a4/html5/thumbnails/26.jpg)
Big Picture
• Relative clauses:– The operator and the np(x) has to be in
the same branch.– The operator has to dominate the np(x).– There should be no intervening operators
between the operator and the variable.
![Page 27: Review of Homework 4 November 20, 2003. Exercise 1 (A) 1 pt Modify the DCG to accept the omission of the complementizer that for object relative clauses](https://reader036.vdocuments.us/reader036/viewer/2022081602/551c43f75503469d6a8b45a4/html5/thumbnails/27.jpg)
Exercise 5:– 4. Mary hit the man that the cat that
John saw hissed at – 5. *Mary hit the man that the cat that
John saw Mary hissed at • (4) is a doubly-embedded object relative
sentence• (4) and (5) satisfy both filters
![Page 28: Review of Homework 4 November 20, 2003. Exercise 1 (A) 1 pt Modify the DCG to accept the omission of the complementizer that for object relative clauses](https://reader036.vdocuments.us/reader036/viewer/2022081602/551c43f75503469d6a8b45a4/html5/thumbnails/28.jpg)
Exercise 5: Multiple Embeddings2pt
• Homework Question:– Modify filter2/1, i.e. operator/1, to reject example 5:
5. *Mary hit the man that the cat that John saw Mary hissed at
In other words:– Modify operator/1 from succeeding for zero np(x)s– Operator/1 should succeed only for the case wher
e there is exactly one np(x) present
![Page 29: Review of Homework 4 November 20, 2003. Exercise 1 (A) 1 pt Modify the DCG to accept the omission of the complementizer that for object relative clauses](https://reader036.vdocuments.us/reader036/viewer/2022081602/551c43f75503469d6a8b45a4/html5/thumbnails/29.jpg)
filter2(X) :- operator(X).
lt2vars(np(x),F) :- var(F), F = one.lt2vars(X,F) :- X =.. [_,A1,A2], \+ X = lambda(x,_),
lt2vars(A1,F),lt2vars(A2,F).lt2vars(X,F) :- X =.. [_,A1,A2], X = lambda(x,_).lt2vars(X,F) :- \+ X = np(x), X =.. [_,A], lt2vars(A,F).lt2vars(X,_) :- atom(X).
operator(lambda(x,Y),F):- lt2vars(Y,F).operator(X,F) :- X =.. [_,A1,_], operator(A1,F).operator(X,F) :- X =.. [_,_,A2], operator(A2,F).operator(X,F) :- X =.. [_,A], operator(A,F).
Original clauses
This successfully excludes cases where there are two np(x)s bound by one operator.
BUT, this does NOT exclude an operator binding ZERO np(x).
![Page 30: Review of Homework 4 November 20, 2003. Exercise 1 (A) 1 pt Modify the DCG to accept the omission of the complementizer that for object relative clauses](https://reader036.vdocuments.us/reader036/viewer/2022081602/551c43f75503469d6a8b45a4/html5/thumbnails/30.jpg)
np
np
det
the
n
cat
lambda
x s
np
np vp
vjohn
saw mary
*Mary hit the man that the cat that John saw Mary hissed at
np
vp
v
hissed at x
lambda
x s
![Page 31: Review of Homework 4 November 20, 2003. Exercise 1 (A) 1 pt Modify the DCG to accept the omission of the complementizer that for object relative clauses](https://reader036.vdocuments.us/reader036/viewer/2022081602/551c43f75503469d6a8b45a4/html5/thumbnails/31.jpg)
Solution• lt2vars(np(x),F) :- var(F), F = one.
• operator(lambda(x,Y)):- lt2vars(Y,F), var(F).
• filter2(X) :- \+ operator(X).
2+ np(x) 1 np(x) 0 np(x)
![Page 32: Review of Homework 4 November 20, 2003. Exercise 1 (A) 1 pt Modify the DCG to accept the omission of the complementizer that for object relative clauses](https://reader036.vdocuments.us/reader036/viewer/2022081602/551c43f75503469d6a8b45a4/html5/thumbnails/32.jpg)
An alternativefilter2(X) :- \+ ( operator(X,F), var(F)).
![Page 33: Review of Homework 4 November 20, 2003. Exercise 1 (A) 1 pt Modify the DCG to accept the omission of the complementizer that for object relative clauses](https://reader036.vdocuments.us/reader036/viewer/2022081602/551c43f75503469d6a8b45a4/html5/thumbnails/33.jpg)
A better solution that takes care of even the 2nd extra credits
• lt2vars(np(x),F) :-
(var(F) -> F = one(_)); F = one(two).
• operator(lambda(x,Y)):- lt2vars(Y,F), (var(F) ; F == one(two)).
• filter2(X) :- \+ operator(X).
2+ np(x) 1 np(x) 0 np(x)
![Page 34: Review of Homework 4 November 20, 2003. Exercise 1 (A) 1 pt Modify the DCG to accept the omission of the complementizer that for object relative clauses](https://reader036.vdocuments.us/reader036/viewer/2022081602/551c43f75503469d6a8b45a4/html5/thumbnails/34.jpg)
Term projects?Final take-home exam: 12/9-12/16