LING 388: Language and Computers - PowerPoint PPT Presentation

1 / 29
About This Presentation
Title:

LING 388: Language and Computers

Description:

Step 3: Propagate the number feature up to the rule where the verb phrase meets ... Add the number feature for NP and propagate this down to ball/balls ... – PowerPoint PPT presentation

Number of Views:49
Avg rating:3.0/5.0
Slides: 30
Provided by: sandiw
Category:

less

Transcript and Presenter's Notes

Title: LING 388: Language and Computers


1
LING 388 Language and Computers
  • Sandiway Fong
  • Lecture 13 10/11

2
Administrivia
  • Computer Laboratory Class
  • homework 3 to be handed out
  • due next Monday (18th October)
  • email sandiway_at_email.arizona.edu (by midnight)
  • Homework 2
  • handed back today
  • or available in the yellow folder in my mailbox
    in Linguistics (Douglass building)
  • Next Time
  • back in Harvill

3
Last Time
  • Case study
  • How to implement the passive construction
  • verb inflection
  • constraints between auxiliary and main verbs
  • subcategorization and adjuncts

4
Todays Topic
  • Well take the grammar weve been developing so
    far and explore adding more constraints

5
Example Grammar
  • s(s(Y,Z)) --gt np(Y), vp(Z).
  • np(np(Y)) --gt pronoun(Y).
  • np(np(D,N)) --gt det(D,Number), common_noun(N,Numbe
    r).
  • det(det(the),_) --gt the.
  • det(det(a),sg) --gt a.
  • common_noun(n(ball),sg) --gt ball.
  • common_noun(n(man),sg) --gt man.
  • common_noun(n(men),pl) --gt men.
  • pronoun(i) --gt i.
  • pronoun(we) --gt we.
  • pronoun(me) --gt me.
  • vp(vp(Y)) --gt unergative(Y).
  • vp(vp(Y,Z)) --gt transitive(Y,_), np(Z).
  • vp(vp(A,V)) --gt aux(A), transitive(V,en).
  • vp(vp(VP,PP)) --gt vp(VP), pp(PP).
  • pp(pp(P,NP)) --gt preposition(P), np(NP).
  • preposition(p(by)) --gt by.
  • unergative(v(ran)) --gt ran.
  • transitive(v(hit),_) --gt hit.
  • Grammar weve been developing so far includes
    passivization and extra arguments for
  • parse tree
  • determiner-noun agreement
  • passive morphology

6
Exercise 1 Passivization
  • Load grammar shown on previous slide into
    SWI-Prolog
  • cut-and-paste directly into a text file
  • also available as file named g13.pl from course
    homepage
  • http//dingo.sbs.arizona.edu/sandiway/ling388n/

7
Exercise 1 Passivization
  • Verify the following sentences are parsed by the
    grammar
  • I hit the ball (active)
  • the ball was hit (passive)
  • the ball was hit by me (passive subject in
    by-phrase)
  • Query
  • ?- s(X,Sentence,).
  • Warning do not hit for more answers, just the
    return key

(non-movement account)
8
Exercise 1 Passivization
  • Homework Question (6pts)
  • Add the grammar rules necessary to parse the
    following sentences
  • the apple was eaten (passive)
  • the apple was eaten by the worm (passive
    by-phrase)
  • john burned the toast
  • the toast was burnt by john
  • Submit both the rules and the output
  • Notes
  • you will need to write a NP rule for proper nouns
    like john
  • use lowercase john (for simplicity in the lexical
    rule)

9
Exercise 2 Left Recursion and the By-Phrase
  • Phrase Structure
  • the ball was hit by me (passive subject in
    by-phrase)
  • PP rules
  • pp(pp(P,NP)) --gt preposition(P), np(NP).
  • preposition(p(by)) --gt by.
  • VP adjunction rule
  • vp(vp(VP,PP)) --gt vp(VP), pp(PP).
  • this rule is left-recursive
  • unfortunately it makes the parser loop
  • on all sentences (not just passive ones
  • with a by-phrase)
  • Hence the warning in Exercise 1...
  • Warning do not hit for more answers, just the
    return key

10
Exercise 2 Left Recursion and the By-Phrase
  • How do we verify that this rule causes the
    grammar to loop?
  • Run following sentence and hit for more answers
  • I hit the ball
  • Output
  • ?- s(X,i,hit,the,ball,).
  • X s(np(i), vp(v(hit), np(det(the), n(ball))))
  • ERROR Out of local stack

11
Exercise 2 Left Recursion and the By-Phrase
  • How do we verify that this rule causes the
    grammar to loop?
  • Remove the rule from the grammar
  • Hint comment it out using Prologs comment
    character
  • ...
  • vp(vp(Y,Z)) --gt transitive(Y,_), np(Z).
  • vp(vp(A,V)) --gt aux(A), transitive(V,en).
  • vp(vp(VP,PP)) --gt vp(VP), pp(PP).
  • pp(pp(P,NP)) --gt preposition(P), np(NP).
  • ...
  • 2. Re-load the grammar and re-run the sentence I
    hit the ball
  • See the difference in behavior when you hit for
    more answers
  • Output
  • ?- s(X,i,hit,the,ball,).
  • X s(np(i), vp(v(hit), np(det(the), n(ball))))
  • No

12
Exercise 2 Left Recursion and the By-Phrase
  • How do we verify that this rule causes the
    grammar to loop?
  • Lets trace the parser and look at how this works
  • Uncomment rule, i.e. put it back into the grammar
  • Hint remove the comment character
  • Re-load the grammar and turn on tracing
  • ?- trace.
  • Step through sentence I hit the ball
  • Pay special attention to what happens after you
    hit for more answers
  • Output
  • ?- s(X,i,hit,the,ball,).
  • X s(np(i), vp(v(hit), np(det(the), n(ball))))

13
Exercise 2 Left Recursion and the By-Phrase
  • Output
  • trace ?- s(X,i,hit,the,ball,).
  • Call (7) s(_G295, i, hit, the, ball, ) ?
    creep
  • Call (8) np(_G359, i, hit, the, ball,
    _G368) ? skip
  • Exit (8) np(np(i), i, hit, the, ball, hit,
    the, ball) ? creep
  • Call (8) vp(_G360, hit, the, ball, ) ?
    creep
  • Call (9) unergative(_G364, hit, the, ball,
    ) ? skip
  • Fail (9) unergative(_G364, hit, the, ball,
    ) ? creep
  • Redo (8) vp(_G360, hit, the, ball, ) ?
    creep
  • Call (9) transitive(_G364, _G372, hit, the,
    ball, _G374) ? skip
  • Exit (9) transitive(v(hit), _G374, hit, the,
    ball, the, ball) ? creep
  • Call (9) np(_G365, the, ball, ) ? skip
  • Exit (9) np(np(det(the), n(ball)), the,
    ball, ) ? creep
  • Exit (8) vp(vp(v(hit), np(det(the),
    n(ball))), hit, the, ball, ) ? creep
  • Exit (7) s(s(np(i), vp(v(hit), np(det(the),
    n(ball)))), i, hit, the, ball, ) ? creep
  • X s(np(i), vp(v(hit), np(det(the), n(ball))))

creep return skip s
14
Exercise 2 Left Recursion and the By-Phrase
vp(vp(Y,Z)) --gt transitive(Y,_),
np(Z). vp(vp(A,V)) --gt aux(A), transitive(V,en). v
p(vp(VP,PP)) --gt vp(VP), pp(PP).
  • Output
  • X s(np(i), vp(v(hit), np(det(the), n(ball))))
  • Redo (10) common_noun(_G370, _G379, ball,
    ) ? skip
  • Fail (10) common_noun(_G370, _G379, ball,
    ) ? skip
  • Fail (10) det(_G369, _G377, the, ball,
    _G379) ? skip
  • Fail (9) np(_G365, the, ball, ) ? skip
  • Fail (9) transitive(_G364, _G372, hit, the,
    ball, _G374) ? skip
  • Redo (8) vp(_G360, hit, the, ball, ) ?
    creep
  • Call (9) aux(_G364, hit, the, ball, _G373)
    ? skip
  • Fail (9) aux(_G364, hit, the, ball, _G373)
    ? creep
  • Redo (8) vp(_G360, hit, the, ball, ) ?
    creep
  • Call (9) vp(_G364, hit, the, ball, _G373) ?
    skip
  • Exit (9) vp(vp(v(hit), np(det(the),
    n(ball))), hit, the, ball, ) ? creep
  • Call (9) pp(_G365, , ) ? skip
  • Fail (9) pp(_G365, , ) ? creep

15
Exercise 2 Left Recursion and the By-Phrase
vp(vp(Y,Z)) --gt transitive(Y,_),
np(Z). vp(vp(A,V)) --gt aux(A), transitive(V,en). v
p(vp(VP,PP)) --gt vp(VP), pp(PP).
  • Output
  • Redo (11) common_noun(_G373, _G382, ball,
    _G384) ? skip
  • Fail (11) common_noun(_G373, _G382, ball,
    _G384) ? skip
  • Fail (11) det(_G372, _G380, the, ball,
    _G382) ? skip
  • Fail (10) np(_G368, the, ball, _G378) ?
    skip
  • Fail (10) transitive(_G367, _G375, hit, the,
    ball, _G377) ? skip
  • Redo (9) vp(_G364, hit, the, ball, _G373) ?
    creep
  • Call (10) aux(_G367, hit, the, ball, _G376)
    ? skip
  • Fail (10) aux(_G367, hit, the, ball, _G376)
    ? creep
  • Redo (9) vp(_G364, hit, the, ball, _G373) ?
    creep
  • Call (10) vp(_G367, hit, the, ball, _G376)
    ? skip
  • Exit (10) vp(vp(v(hit), np(det(the),
    n(ball))), hit, the, ball, ) ? creep
  • Call (10) pp(_G368, , _G388) ?

16
Exercise 2 Left Recursion and the By-Phrase
  • Homework Question (4pts)
  • Explain in your own words step-by-step why the
    Prolog computation rule successfully parses the
    sentence
  • the ball was hit by me
  • but then goes into an infinite loop when asked
    for more answers
  • Submit your prose and both the trace and your
    output highlighting where the parser loops
  • Extra Credit Homework Question (5pts)
  • Suggest how we can fix the problem
  • give a concrete suggestion
  • i.e. dont just simply say eliminate the left
    recursion
  • If you can, implement your suggestion and submit
    the grammar and output

17
Exercise 3 Subject-Verb Agreement
  • From last lecture ...
  • Examples
  • I hit the ball (active)
  • the ball was hit (passive)
  • the ball were hit
  • the balls was hit
  • the balls were hit
  • Subject-Verb Agreement Rule
  • subject must agree with the verb for number

18
Exercise 3 Subject-Verb Agreement
  • Examples
  • I hit the ball (active)
  • the ball was hit (passive)
  • the ball were hit
  • the balls was hit
  • the balls were hit
  • Step 1 Implement was/were
  • vp(vp(A,V)) --gt aux(A), transitive(V,en).
  • aux(aux(was)) --gt was.
  • aux(aux(were)) --gt were.

19
Exercise 3 Subject-Verb Agreement
  • Examples
  • I hit the ball (active)
  • the ball was hit (passive)
  • the ball were hit
  • the balls was hit
  • the balls were hit
  • Step 2 Implement the number feature for was/were
  • vp(vp(A,V)) --gt aux(A,Number), transitive(V,en).
  • aux(aux(was),sg) --gt was.
  • aux(aux(were),pl) --gt were.

20
Exercise 3 Subject-Verb Agreement
  • Examples
  • I hit the ball (active)
  • the ball was hit (passive)
  • the ball were hit
  • the balls was hit
  • the balls were hit
  • Step 3 Propagate the number feature up to the
    rule where the verb phrase meets the subject (for
    subject-verb agreement)
  • s(s(Y,Z)) --gt np(Y), vp(Z,Number).
  • vp(vp(A,V),Number) --gt aux(A,Number),
    transitive(V,en).

21
Exercise 3 Subject-Verb Agreement
  • Examples
  • I hit the ball (active)
  • the ball was hit (passive)
  • the ball were hit
  • the balls was hit
  • the balls were hit
  • Step 4 Subject noun phrase (NP) must agree with
    the Number value for the verb phrase (VP)
  • Add the number feature for NP and propagate this
    down to ball/balls
  • s(s(Y,Z)) --gt np(Y,Number), vp(Z,Number).
  • vp(vp(A,V),Number) --gt aux(A,Number),
    transitive(V,en).
  • np(np(D,N),Number) --gt det(D,Number),
    common_noun(N,Number).
  • det(det(the),_) --gt the.
  • det(det(a),sg) --gt a.
  • common_noun(n(ball),sg) --gt ball.
  • common_noun(n(balls),pl) --gt balls.

22
Exercise 3 Subject-Verb Agreement
  • Examples
  • I hit the ball (active)
  • the ball was hit (passive)
  • the ball were hit
  • the balls was hit
  • the balls were hit
  • Step 5 Add the number feature for all types of
    NPs
  • np(np(D,N),Number) --gt det(D,Number),
    common_noun(N,Number).
  • np(np(Y),Number) --gt pronoun(Y,Number).
  • pronoun(i,sg) --gt i.
  • pronoun(we,pl) --gt we.
  • pronoun(me,sg) --gt me.

23
Exercise 3 Subject-Verb Agreement
  • Verify that the following examples can be parsed
    now
  • Examples
  • the ball was hit
  • the ball were hit
  • the balls was hit
  • the balls were hit
  • Output
  • ?- s(X,the,balls,were,hit,).
  • X s(np(det(the), n(balls)), vp(aux(were),
    v(hit)))
  • Yes
  • ?- s(X,the,balls,was,hit,).
  • No
  • ?- s(X,the,ball,were,hit,).
  • No
  • ?- s(X,the,ball,was,hit,).
  • X s(np(det(the), n(ball)), vp(aux(was),
    v(hit)))
  • Yes

24
Exercise 3 Subject-Verb Agreement
  • Homework Question (4pts)
  • Examples
  • I hit the ball (active)
  • the ball was hit (passive)
  • the ball were hit
  • the balls was hit
  • the balls were hit
  • The active example sentence now no longer works
  • ?- s(X,i,hit,the,ball,).
  • No
  • Why? Fix the grammar.
  • Submit both your grammar and the output

25
Exercise 4 Morphological Case
  • Examples
  • I hit the ball
  • me hit the ball
  • the ball hit me
  • the ball hit I
  • the ball was hit by me
  • the ball was hit by I
  • First person pronouns in English inflect for
    morphological case endings
  • I nominative
  • me accusative
  • we nominative
  • us accusative

26
Exercise 4 Morphological Case
  • Examples
  • I hit the ball
  • me hit the ball
  • the ball hit me
  • the ball hit I
  • the ball was hit by me
  • the ball was hit by I
  • Use original grammar g13.pl (back at the
    beginning of this class)
  • Add an extra parameter to specify case
  • Rules
  • np(np(Y),Case) --gt pronoun(Y,Case).
  • pronoun(i,nom) --gt i.
  • pronoun(we,nom) --gt we.
  • pronoun(me,acc) --gt me.

27
Exercise 4 Morphological Case
  • Examples
  • I hit the ball
  • me hit the ball
  • the ball hit me
  • the ball hit I
  • the ball was hit by me
  • the ball was hit by I
  • Case constraint
  • subjects must have nominative case
  • Rule
  • s(s(Y,Z)) --gt np(Y,nom), vp(Z).
  • Verify the first two example sentences work
  • ?- s(X,i,hit,the,ball,).
  • X s(np(i), vp(v(hit), np(det(the), n(ball))))
  • ?- s(X,me,hit,the,ball,).
  • No

28
Exercise 4 Morphological Case
  • Examples
  • I hit the ball
  • me hit the ball
  • the ball hit me
  • the ball hit I
  • the ball was hit by me
  • the ball was hit by I
  • Homework Question (6pts)
  • Implement the constraints necessary to handle the
    remaining four example sentences
  • Submit both your grammar and the output

29
Homework Summary
  • Homework
  • Question 1 (6pts)
  • Question 2 (4pts)
  • Question 3 (4pts)
  • Question 4 (6pts)
  • Total 20 pts
  • Extra Credit
  • Question 2 (5pts)
Write a Comment
User Comments (0)
About PowerShow.com