<< Prev | - Up - |
The purpose of Practical Session 8 is to help you get familiar with DCGs that make use of additional arguments and tests.
First some keyboard exercises:
Trace some examples using the DCG which uses extra arguments to handle the subject/object distinct, the DCG which produces parses, and the DCG which uses extra tests to separate lexicon and rules. Make sure you fully understand the way all three DCGs work.
Carry out traces on the DCG for that was given in the text (that is, the DCG that gave the Count
variable the values 0
, succ(0)
, succ(succ(0))
, and so on). Try cases where the three blocks of a
s, b
s, and c
s are indeed of the same length as well as queries where this is not the case.
Now for some programming. We suggest two exercises.
First, bring together all the things we have learned about DCGs for English into one DCG. In particular, today we say how to use extra arguments to deal with the subject/object distinction, and in the exercises you were asked to use additional arguments to deal with the singular/plural distinction. Write a DCG which handles both. Moreover, write the DCG in such a way that it will produce parse trees, and makes use of a separate lexicon.
Once you have done this, extend the DCG so that noun phrases can be modified by adjectives and simple prepositional phrases (that is, it should be able to handle noun phrases such as ``the small frightened woman on the table'' or ``the big fat cow under the shower''). Then, further extend it so that the distinction between first, second, and third person pronouns is correctly handled (both in subject and object form).
<< Prev | - Up - |