Homework 7
Due Monday, November 13
Intro
This homework relates to classes.
Rewrite the CKY code we developed in class
(/home/rws/CodeFall06/cky.py) so that the chart, which we had
defined as a dictionary, is defined as a class. The chart
class would have a dictionary as the main data structure as before,
but it would "hide" that from the user in that they would not have to
deal directly with the dictionary operations. Your chart class should
support:
-
Insertion of an element into a position i, j; as
before, if there is already an element there, you would simply add
another element. That is, you would append the new element to an
already existing list of elements.
-
Retrieving an element from the chart in a position i, j.
-
Deletion of all elements in a position i, j.
-
Clearing: deletion of all elements everywhere in the chart.
-
Print: print the contents of the chart.
-
Accept: boolean operator that tells whether a chart is complete, for
some sentence length n, in that it has an entry in the
0, n position.