Natural Language Processing – Summer 2006

advertisement
Natural Language Processing – Summer 2006
Tutorial sheet 2 – Syntactic parsing
Your name:
Your course:
Student Number:
Exercise 1. (Exercise 9.6 - Speech and Language Processing)
Assume a grammar that has differently subcategorized verb rules:
Verb-with-NP-complement  find | leave | repeat | ...
Verb-with-S-complement  think | believe | say | …
Verb-with-Inf- VP-complement  want | try | need | ...
and many VPs rules for different subcategorization:
VP  Verb-with-no-complement
disappear
VP  Verb-with-NP-comp NP
prefer a morning flight
VP  Verb-with-S-comp S
said there were two flights
How would the rule for post-nominal relative clauses
RelClause  (who | that) VP
need to be modified if we wanted to deal properly with examples like “the earliest flight that
you have”?
Exercise 2. Bottom-up Parsing
(Backtrack parsing with reduce-preference)
(i) Show a bottom-up backtracking parse of the sentence
“The princess rose and spoke"
det
n
n,v conj n,v
where lexical categories are as indicated (and are tried in that order), and where the grammar
rules are as follows (and are tried in that order):
S  NP VP
N  N CONJ N
NNN
NP  Det N
V  V CONJ V
VP  V
Assume that reductions are tried before shifts, and that reductions must always include the
rightmost element of the current state. In showing the trace, use the format illustrated in class
(showing the current state adjacent to the “remainder" of the sentence, with a separating line,
and placing backup states to the left as they are created, and with downward arrows indicating
the later use of these backup states as new current state).
(ii) For at least one backup state in the trace you obtained, explain why that state is
“nonviable" from the outset, i.e., it could never lead to an S-parse, given the grammar and
lexicon under consideration.
Exercise 3. (Exercise 10.2 - Speech and Language Processing).
Write an algorithm (in pseudo-code) for eliminating left-recursion based on the intutition on
page 370 (Section 10.3 - Speech and Language Processing)
Exercise 4. Consider the following sentences:
ListA
i. Joe is reading the book.
ii. Joe had won a letter.
iii. Joe has to win.
iv. Joe will have the letter.
v. The letter in the book was read.
ListB
i. *Joe has reading the book.
ii. *Joe had win.
iii. *Joe winning.
iv. *Joe will had the letter.
v. *The book was win by Joe.
vi. The letter must have been in the book by Joe.
vii. The man could have had one.
vi. *Joe will can be mad.
vii. *The man can have having one.
a. Write a context-free grammar that accepts all the sentences in list A while rejecting the sentences in
list B. You may find it useful to make reference to the grammatical forms of verbs in the following
tables [Allen 1995: Linguistic Background: An Outline of English Syntax 29]:
Tense
The Verb Sequence
Example
simple present
simple past
simple future
present perfect
simple present
simple past
will + infinitive
have in present
+ past participle
will + have in infinitive
+ past participle
have in past
+ past participle
He walks to the store.
He walked to the store.
He will walk to the store.
He has walked to the store.
future perfect
past perfect
(or pluperfect)
I will have walked to the store.
I had walked to the store.
Table 1 - The basic tenses
Tense
present progressive
past progressive
future progressive
present perfect progressive
future perfect progressive
past perfect progressive
Structure
be in present
+ present participle
be in past
+ present participle
will + be in infinitive
+ present participle
have in present
+ be in past participle
+ present participle
will + have in present
+ be as past participle
+ present participle
have in past
+ be in past participle
+ present participle
Example
He is walking.
He was walking.
He will be walking.
He has been walking.
He will have been walking.
He had been walking.
Table 2 - The progressive tenses
b. Implement one of the chart-based parsing strategies (in pseudo-code) and, using the grammar
specified in part (a), demonstrate that your parser correctly accepts all the sentences in A and rejects
those in B. You should maintain enough information in each entry on the chart so that you can
reconstruct the parse tree for each possible interpretation. Make sure your method of recording the
structure is well documented and clearly demonstrated.
c. List three (distinct) grammatical forms that would not be recognized by a parser implementing the
grammar in part (a). Provide an example of your own for each of these grammatical forms.
Download