Package nltk_lite :: Package contrib :: Package mit :: Package six863 :: Package parse :: Module featurelite :: Class Variable
[hide private]
[frames] | no frames]

Class Variable

source code

object --+
         |
        Variable

A Variable is an object that can be used in unification to hold an initially unknown value. Two equivalent Variables, for example, can be used to require that two features have the same value.

When a Variable is assigned a value, it will eventually be replaced by that value. However, in order to make that value show up everywhere the variable appears, the Variable temporarily stores its assigned value and becomes a bound variable. Bound variables do not appear in the results of unification.

Variables are distinguished by their name, and by the dictionary of bindings that is being used to determine their values. Two variables can have the same name but be associated with two different binding dictionaries: those variables are not equal.

Instance Methods [hide private]
 
__init__(self, name=None, value=None)
Construct a new feature structure variable.
source code
string
name(self)
Returns: This variable's name.
source code
object
value(self)
If this varable is bound, find its value.
source code
Variable
copy(self)
Returns: A copy of this variable.
source code
Variable
forwarded_self(self)
Variables are aliased to other variables by one variable _forwarding_ to the other.
source code
 
bindValue(self, value, ourbindings, otherbindings)
Bind this variable to a value.
source code
Variable
forwardTo(self, other, ourbindings, otherbindings)
A unification wants this variable to be aliased to another variable.
source code
 
__hash__(self)
hash(x)
source code
 
__cmp__(self, other)
Variables are equal if they are the same object or forward to the same object.
source code
 
__repr__(self)
repr(x)
source code

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

Class Variables [hide private]
  _next_numbered_id = 1
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, name=None, value=None)
(Constructor)

source code 

Construct a new feature structure variable.

The value should be left at its default of None; it is only used internally to copy bound variables.

Parameters:
  • name (string) - An identifier for this variable. Two Variable objects with the same name will be given the same value in a given dictionary of bindings.
Overrides: object.__init__

name(self)

source code 
Returns: string
This variable's name.

value(self)

source code 

If this varable is bound, find its value. If it is unbound or aliased to an unbound variable, returns None.

Returns: object
The value of this variable, if any.

copy(self)

source code 
Returns: Variable
A copy of this variable.

forwarded_self(self)

source code 

Variables are aliased to other variables by one variable _forwarding_ to the other. The first variable simply has the second as its value, but it acts like the second variable's _value_ is its value.

forwarded_self returns the final Variable object that actually stores the value.

Returns: Variable
The Variable responsible for storing this variable's value.

bindValue(self, value, ourbindings, otherbindings)

source code 

Bind this variable to a value. ourbindings are the bindings that accompany the feature structure this variable came from; otherbindings are the bindings from the structure it's being unified with.

Parameters:
  • value (object) - The value to be assigned.
  • ourbindings (dict) - The bindings associated with this variable.
  • otherbindings (dict) - The bindings associated with the value being assigned. (May be identical to ourbindings.)

forwardTo(self, other, ourbindings, otherbindings)

source code 

A unification wants this variable to be aliased to another variable. Forward this variable to the other one, and return the other.

Parameters:
  • other (Variable) - The variable to replace this one.
  • ourbindings (dict) - The bindings associated with this variable.
  • otherbindings (dict) - The bindings associated with the other variable. (May be identical to ourbindings.)
Returns: Variable
other

__hash__(self)
(Hashing function)

source code 

hash(x)

Overrides: object.__hash__
(inherited documentation)

__cmp__(self, other)
(Comparison operator)

source code 

Variables are equal if they are the same object or forward to the same object. Variables with the same name may still be unequal.

__repr__(self)
(Representation operator)

source code 

repr(x)

Overrides: object.__repr__
(inherited documentation)