Package jazzparser :: Package parsers :: Package cky :: Module chart :: Class SignHashSet
[hide private]
[frames] | no frames]

Class SignHashSet

source code

  object --+    
           |    
data.HashSet --+
               |
              SignHashSet
Known Subclasses:

Based on the basic hash set implementation. Provides special behaviour for adding already existing signs, so that, e.g., the derivation traces get added when a new sign is an alternative derivation of an already existing one.

SignHashSet additionally stores and maintains an index of the signs by category. It is useful during parsing to get just the distinct categories, since all the signs with the same category will be subject to the same rule applications.

Instance Methods [hide private]
 
__init__(self, formalism, derivation_traces=False)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
append(self, new_entry)
Overrides append() to maintain the index of signs grouped by category.
source code
 
remove(self, entry)
Overrides remove() to maintain the index of signs grouped by category.
source code
 
_add_existing_value(self, existing_value, new_value)
When a value already exists in the table, this is called instead of adding the value.
source code
 
get_distinct_categories(self)
Returns: a list containing one of each of the distinct syntactic categories found among the signs in this set.
source code
list of lists of Signs
get_signs_grouped_by_category(self)
Returns: all the signs in the set, grouped into lists of signs sharing the same syntactic category.
source code
list of Signs
get_signs_by_category(self, category)
Returns: all the signs in the set that have a category equal to that given.
source code

Inherited from data.HashSet: __contains__, __len__, extend, values

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, formalism, derivation_traces=False)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

append(self, new_entry)

source code 

Overrides append() to maintain the index of signs grouped by category.

See jazzparser.data.HashSet for main doc.

Overrides: data.HashSet.append

remove(self, entry)

source code 

Overrides remove() to maintain the index of signs grouped by category.

See jazzparser.data.HashSet for main doc.

Overrides: data.HashSet.remove

_add_existing_value(self, existing_value, new_value)

source code 

When a value already exists in the table, this is called instead of adding the value. By default, it does nothing (i.e. drops the new value), but you can override it if you want to do something else to combine the values.

Note that your custom methods must only modify the sign that's already in the set (existing_value), not add a new sign and not modify new_value.

Overrides: data.HashSet._add_existing_value
(inherited documentation)

get_distinct_categories(self)

source code 
Returns:
a list containing one of each of the distinct syntactic categories found among the signs in this set.

get_signs_grouped_by_category(self)

source code 
Returns: list of lists of Signs
all the signs in the set, grouped into lists of signs sharing the same syntactic category.

get_signs_by_category(self, category)

source code 
Returns: list of Signs
all the signs in the set that have a category equal to that given.