Package nltk_lite :: Package parse :: Module category :: Class Category
[show private | hide private]
[frames | no frames]

Type Category

      object --+    
               |    
FeatureStructure --+
                   |
      object --+   |
               |   |
     Nonterminal --+
                   |
                  Category

Known Subclasses:
GrammarCategory

A Category is a specialized feature structure, intended for use in parsing. It can act as a Nonterminal.

A Category differs from a FeatureStructure in these ways:
Method Summary
  __init__(self, **features)
  __cmp__(self, other)
  __div__(self, other)
Return a new Category based on this one, with its / feature set to other.
bool __eq__(self, other)
Return true if self and other assign the same value to to every feature.
  __hash__(self)
boolean __ne__(self, other)
Return true if this non-terminal is not equal to other.
  __repr__(self)
Return a string representation of this feature structure.
  __setitem__(self, name, value)
  deepcopy(self, memo)
Return a deep copy of self.
  feature_names(self)
Return a list of all features that have values.
  freeze(self)
Freezing a Category memoizes its hash value, to make comparisons on it faster.
bool frozen(self)
Returns whether this Category is frozen (immutable).
  get_feature(self, *args)
  has_feature(self, name)
str or None head(self)
Return the head of this category (the value shown outside the brackets in its string representation).
  parse_rules(cls, s)
Parse a CFG line involving Categories. (Class method)
list of FeatureStructure reentrances(self)
Return a list of all feature structures that can be reached from self by multiple feature paths.
  remove_unbound_vars(self)
  required_features(self)
Return a list of the names of all required features.
Category symbol(self)
Return the node value corresponding to this Category.
Inherited from FeatureStructure: __getitem__, __str__, apply_bindings, equal_values, parse, rename_variables, subsumes, unify
Inherited from object: __delattr__, __getattribute__, __new__, __reduce__, __reduce_ex__, __setattr__

Class Variable Summary
str headname = '_head'
str k = 'reentrance'
list requiredFeatures = []
SRE_Pattern v = \s*->\s*

Instance Method Details

__div__(self, other)

Returns:
A new Category based on this one, with its / feature set to other.
Overrides:
nltk_lite.parse.cfg.Nonterminal.__div__

__eq__(self, other)
(Equality operator)

Returns:
True if self and other assign the same value to to every feature. In particular, return true if self[p]==other[p] for every feature path p such that self[p] or other[p] is a base value (i.e., not a nested Category).
           (type=bool)
Overrides:
nltk_lite.parse.featurestructure.FeatureStructure.__eq__

__ne__(self, other)

Returns:
True if this non-terminal is not equal to other. In particular, return true iff other is not a Nonterminal or this non-terminal's symbol is not equal to other's symbol.
           (type=boolean)
Overrides:
nltk_lite.parse.cfg.Nonterminal.__ne__ (inherited documentation)

__repr__(self)
(Representation operator)

Returns:
A string representation of this feature structure.
Overrides:
nltk_lite.parse.featurestructure.FeatureStructure.__repr__

deepcopy(self, memo=None)

Returns:
A deep copy of self.
Overrides:
nltk_lite.parse.featurestructure.FeatureStructure.deepcopy

feature_names(self)

Returns:
a list of all features that have values.
Overrides:
nltk_lite.parse.featurestructure.FeatureStructure.feature_names

freeze(self)

Freezing a Category memoizes its hash value, to make comparisons on it faster. After freezing, the Category and all its values are immutable.
Returns:
self

frozen(self)

Returns whether this Category is frozen (immutable).
Returns:
bool

head(self)

Returns:
The head of this category (the value shown outside the brackets in its string representation). If there is no head, returns None.
           (type=str or None)

reentrances(self)

Returns:
A list of all feature structures that can be reached from self by multiple feature paths.
           (type=list of FeatureStructure)
Overrides:
nltk_lite.parse.featurestructure.FeatureStructure.reentrances (inherited documentation)

required_features(self)

Returns:
A list of the names of all required features.

symbol(self)

Returns:
The node value corresponding to this Category.
           (type=Category)
Overrides:
nltk_lite.parse.cfg.Nonterminal.symbol

Class Method Details

parse_rules(cls, s)

Parse a CFG line involving Categories. A line has this form:

lhs -> rhs | rhs | ...

where lhs is a Category, and each rhs is a sequence of Categories.
Returns:
a list of Productions, one for each rhs.

Class Variable Details

headname

Type:
str
Value:
'_head'                                                                

k

Type:
str
Value:
'reentrance'                                                           

requiredFeatures

Type:
list
Value:
[]                                                                     

v

Type:
SRE_Pattern
Value:
\s*->\s*                                                               

Generated by Epydoc 2.1 on Tue Sep 5 09:37:21 2006 http://epydoc.sf.net