Package nltk_lite :: Package parse :: Module featurestructure :: Class FeatureVariable
[show private | hide private]
[frames | no frames]

Class FeatureVariable

SubstituteBindingsI --+
                      |
                     FeatureVariable

Known Subclasses:
AliasedFeatureVariable

A variable that can stand for a single feature value in a feature structure. Each variable is defined by a unique identifier, which can be either a case-sensitive string (for named variables) or an integer (for numbered variables).

Named variables are created by calling the FeatureVariable constructor with a string identifier. If multiple named variables objects are created with the same identifier, then they represent the same variable. Numbered variables are created by calling the FeatureVariable constructor with no arguments; a new identifier will be automatically generated. Each new numbered variable object is guaranteed to have a unique identifier.

Variables do not directly contain values; instead, the mapping from variables to values is encoded externally as a set of bindings, using FeatureBindings. If a set of bindings assigns a value to a variable, then that variable is said to be bound with respect to those bindings; otherwise, it is said to be unbound.

See Also: FeatureStructure

Method Summary
  __init__(self, identifier)
Construct a new feature structure variable.
  __cmp__(self, other)
  __hash__(self)
  __repr__(self)
Return a string representation of this feature structure variable.
AliasedFeatureVariable alias(self, variable)
Return an aliased variable that constrains this variable to be equal to variable.
string identifier(self)
Return this variable's unique identifier.
  parse(s)
Given a string that encodes a feature variable, return that variable. (Static method)
(any) substitute_bindings(self, bindings)
Return the value that is bound to this variable if it appears in @bindings otherwise just return self.

Class Variable Summary
int _next_numbered_id = 1                                                                     

Instance Method Details

__init__(self, identifier=None)
(Constructor)

Construct a new feature structure variable.
Parameters:
identifier - A unique identifier for this variable. Any two FeatureVariable objects with the same identifier are treated as the same variable.
           (type=string)

__repr__(self)
(Representation operator)

Returns:
A string representation of this feature structure variable. A feature structure variable with identifier x is represented as '?x'.

alias(self, variable)

Return an aliased variable that constrains this variable to be equal to variable.
Returns:
AliasedFeatureVariable

identifier(self)

Returns:
This variable's unique identifier.
           (type=string)

substitute_bindings(self, bindings)

Returns:
The value that is bound to this variable if it appears in @bindings otherwise just return self.
           (type=(any))
Overrides:
nltk_lite.parse.featurestructure.SubstituteBindingsI.substitute_bindings

Static Method Details

parse(s)

Given a string that encodes a feature variable, return that variable. This method can be used to parse both FeatureVariables and AliasedFeatureVariables. However, this method can not be used to parse numbered variables, since doing so could violate the guarantee that each numbered variable object has a unique identifier.

Class Variable Details

_next_numbered_id

Type:
int
Value:
1                                                                     

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