Package nltk :: Package sem :: Module evaluate :: Class Assignment
[hide private]
[frames] | no frames]

Class Assignment

source code

object --+    
         |    
      dict --+
             |
            Assignment

A dictionary which represents an assignment of values to variables.

An assigment can only assign values from its domain.

If an unknown expression a is passed to a model M's interpretation function i, i will first check whether M's valuation assigns an interpretation to a as a constant, and if this fails, i will delegate the interpretation of a to g. g only assigns values to individual variables (i.e., members of the class IndividualVariableExpression in the logic module. If a variable is not assigned a value by g, it will raise an Undefined exception.

Instance Methods [hide private]
new empty dictionary

__init__(self, domain, iter=None)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
__getitem__(self, key)
x[y]
source code
a shallow copy of D
copy(self) source code
 
purge(self, var=None)
Remove one or all keys (i.e.
source code
 
__str__(self)
Pretty printing for assignments.
source code
 
_addvariant(self)
Create a more pretty-printable version of the assignment.
source code
 
add(self, var, val)
Add a new variable-value pair to the assignment, and update self.variant.
source code

Inherited from dict: __cmp__, __contains__, __delitem__, __eq__, __ge__, __getattribute__, __gt__, __hash__, __iter__, __le__, __len__, __lt__, __ne__, __new__, __repr__, __setitem__, clear, fromkeys, get, has_key, items, iteritems, iterkeys, itervalues, keys, pop, popitem, setdefault, update, values

Inherited from object: __delattr__, __reduce__, __reduce_ex__, __setattr__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, domain, iter=None)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Parameters:
  • domain (set) - the domain of discourse
  • assignment - a map from variable names to values
Returns:
new empty dictionary

Overrides: dict.__init__

__getitem__(self, key)
(Indexing operator)

source code 

x[y]

Overrides: dict.__getitem__
(inherited documentation)

copy(self)

source code 
Returns: a shallow copy of D
Overrides: dict.copy
(inherited documentation)

purge(self, var=None)

source code 

Remove one or all keys (i.e. logic variables) from an assignment, and update self.variant.

Parameters:
  • var - a Variable acting as a key for the assignment.

__str__(self)
(Informal representation operator)

source code 

Pretty printing for assignments. {'x', 'u'} appears as 'g[u/x]'

Overrides: object.__str__