Due Sunday, 2006-11-19
Download
these six Python modules:
utils.py,
entity.py,
unify.py,
utterance.py,
lex.py, and
parse.py.
parse imports lex, which imports everything else (eventually).
You will be changing lex (and possibly utterance.py); you shouldn't need to change anything else.
The program performs a kind of rudimentary parsing (see the comments at the top of
parse.py), but it doesn't implement any sort of subject-verb agreement.
You'll make the changes needed to make the work (in a limited way).
There are a number of changes to the program since the last assignment, most of which you don't have to be concerned with, but be sure to
read the comments at the top of parse.py.
Sequencing is now handled by Seq objects (defined in utterance.py).
See examples of how they are used in utterance.py and
lex.py.
A Seq object is a dictionary whose keys are tuples representing
an ordered pair and whose values are an "attraction" for the pair (higher means that tend be closer) and a boolean representing whether the ordering is obligatory (all are in this grammar).
Try a few examples of parse() to see how it works.
Note that the second argument is a dictionary; it's not necessary, but you
won't be able to parse "you" or "me" without specifying it.
>>> parse('you sing for arnie', {'speaker': kazuo, 'hearer': almaz})
...
>>> parse('luz sings for arnie', {'speaker': kazuo, 'hearer': almaz})
...
but the following sentence fails:
>>> parse('you sings for arnie', {'speaker': kazuo, 'hearer': almaz})
You should be able to do this with only one additional feature (combine "number" and "person" into one feature with two possible values).
Remember that for any new entry you make, the form must be a string that begins and ends with "|", and the entry must be appended to SENT_LEX or NP_LEX (see lex.py).
If you don't added it to one of these lists, it will never get picked during
parsing.
>>> parse('luz sing for arnie', {'speaker': kazuo, 'hearer': almaz})
but you can make it fail for
>>> parse('luz sing0 for arnie', {'speaker': kazuo, 'hearer': almaz})
For two more points, do that.
>>> parse('luz sing for arnie', {'speaker': kazuo, 'hearer': almaz})