Package parser_course :: Package small_parsers :: Module simple_cky_parser :: Class CKYChart
[hide private]
[frames] | no frames]

Class CKYChart

source code

        object --+        
                 |        
              list --+    
                     |    
offset_list.offsetList --+
                         |
                        CKYChart

A CKY chart is an offset list with some added chart specific methods. An offset list is a list with the indexing offset by 1: Where L[n] is the (n+1)th member of an ordinary Python list, it is the nth member of an offset list. >>> chart[n] returns all the entries for edges of length n in the chart. Thus chart indexes and length can be identified. >>> chart[n][m] returns a dictionary recording all the edges of length n beginning at position m in the string. Note positional list indices do begin with 0. >>> chart[6][0]['vp'] True means a there is a VP edge of length 6 beginning at 0 (the very beginning of the string).

The chart __init__ method requires a grammar, input and parser arguments. The length of the input determines maximum edge length and maximum start positions for each length. The grammar determines dictionary keys for edges of length 1. In accordance with the bottum-up CKY akgorithm, the chart is initialized with all edges of length of 1 as licensed by the input and grammar. This is done by the call to the add_length_one_edges method in __init__.

Instance Methods [hide private]
new list
__init__(self, grammar, input, parser)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
add_length_one_edges(self, grammar, input)
This is the initialization step of CKY in which all edges of length 1 are added to the chart.
source code

Inherited from offset_list.offsetList: __getitem__, __setitem__

Inherited from list: __add__, __contains__, __delitem__, __delslice__, __eq__, __ge__, __getattribute__, __getslice__, __gt__, __hash__, __iadd__, __imul__, __iter__, __le__, __len__, __lt__, __mul__, __ne__, __new__, __repr__, __reversed__, __rmul__, __setslice__, append, count, extend, index, insert, pop, remove, reverse, sort

Inherited from object: __delattr__, __reduce__, __reduce_ex__, __setattr__, __str__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, grammar, input, parser)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Returns: new list
Overrides: object.__init__
(inherited documentation)