| Home | Trees | Index | Help |
|
|---|
| Package nltk_lite :: Package parse :: Module category :: Class Category |
|
object --+
|
FeatureStructure --+
|
object --+ |
| |
Nonterminal --+
|
Category
GrammarCategoryA Category is a specialized feature structure, intended
for use in parsing. It can act as a Nonterminal.
Category differs from a FeatureStructure
in these ways:
repr() representation of a Category, the head goes
to the left, on the outside of the brackets. Subclasses of
Category may change the feature name that is designated
as the head, which is _head by default.
Category may contain a list of
required features, which are names of features whose value is
None if unspecified. A Category lacking a feature that is required in
it will not unify with any Category that has that feature. If a
required feature's value is None, it is considered to be
not present. (Mixing different subclasses of Category is
probably a bad idea.)
True and False are allowed as values. A
feature named foo with a value of True is
simply expressed as +foo. Similarly, if it is
False, it is expressed as -foo.
| Method Summary | |
|---|---|
__init__(self,
**features)
| |
__cmp__(self,
other)
| |
Return a new Category based on this one, with its / feature set
to other. | |
bool
|
Return true if self and other assign the same value
to to every feature. |
__hash__(self)
| |
boolean
|
Return true if this non-terminal is not equal to other. |
Return a string representation of this feature structure. | |
__setitem__(self,
name,
value)
| |
Return a deep copy of self. | |
Return a list of all features that have values. | |
Freezing a Category memoizes its hash value, to make comparisons on it faster. | |
bool
|
Returns whether this Category is frozen (immutable). |
get_feature(self,
*args)
| |
has_feature(self,
name)
| |
str or None
|
Return the head of this category (the value shown outside the brackets in its string representation). |
Parse a CFG line involving Categories. (Class method)
| |
list of FeatureStructure
|
Return a list of all feature structures that can be reached from self by multiple feature paths. |
remove_unbound_vars(self)
| |
Return a list of the names of all required features. | |
Category
|
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)
|
__eq__(self,
other)
|
__ne__(self, other)
|
__repr__(self)
|
deepcopy(self, memo=None)
|
feature_names(self)
|
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.
|
frozen(self)Returns whether this Category is frozen (immutable).
|
head(self)
|
reentrances(self)
|
required_features(self)
|
symbol(self)
|
| Class Method Details |
|---|
parse_rules(cls, s)Parse a
lhs is a Category, and each rhs is a
sequence of Categories.
|
| Class Variable Details |
|---|
headname
|
k
|
requiredFeatures
|
v
|
| Home | Trees | Index | Help |
|
|---|
| Generated by Epydoc 2.1 on Tue Sep 5 09:37:21 2006 | http://epydoc.sf.net |