moses.controlState
Class UnifyResult

java.lang.Object
  |
  +--moses.controlState.UnifyResult

public class UnifyResult
extends java.lang.Object

This class represents the result of a unification (or pattern matching) procedure. It maintains a hashtable that maps variables (names starting with '%' symbol in a matching method) into terms for later retrieval. It provides methods for searching in the hashtable for a specific bound variable which returns either the term or its string representation. A typical usage case for the UnifyResult object follows:


        Term lt = Term.parse("[role(chair,ceo),department(3),active]");
 
        UnifyResult dep =  lt.find("department(%N)");
        
        Term dept =  dep.getTerm(); //returns the whole department term
        Term depno =  dep.getTVar("N"); //returns the number of the department
 
        

In an application, a UnifyResult object is not instantiated directly, but it is return, as in the above example, by one of the find or unify methods of the Term object.


Field Summary
static java.lang.String VAR
           
 java.util.Hashtable vars
           
 
Constructor Summary
UnifyResult()
          Default constructor, not used in applications.
UnifyResult(java.util.Hashtable h)
          Constructor that creates an UnifyResult object out of a provided hashtable.
UnifyResult(java.util.Hashtable h, moses.controlState.Term uterm)
          Constructor that creates an UnifyResult object out of a provided hashtable and a unified complete term.
 
Method Summary
 java.lang.String getSVar(java.lang.String var)
          Returns the string representation of the term bound to variable var provided as argument.
 moses.controlState.Term getTerm()
          This method returns the complete term that has been unified.
 moses.controlState.Term getTVar(java.lang.String var)
          Returns the term bound to the variable provided as argument.
 moses.controlState.Term put(java.lang.String var, moses.controlState.Term t)
          Appends a new binding into the hashtable.
 void setTerm(moses.controlState.Term uterm)
          This method sets the complete term that has been unified.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

vars

public java.util.Hashtable vars

VAR

public static final java.lang.String VAR
See Also:
Constant Field Values
Constructor Detail

UnifyResult

public UnifyResult()
Default constructor, not used in applications.


UnifyResult

public UnifyResult(java.util.Hashtable h)
Constructor that creates an UnifyResult object out of a provided hashtable. It assumes that the hashtable contains only proper Term values (it does not perform any check towards this).
This constructor is not used in user application as well.

Parameters:
h - represents the hashtable that holds variable to term mappings.

UnifyResult

public UnifyResult(java.util.Hashtable h,
                   moses.controlState.Term uterm)
Constructor that creates an UnifyResult object out of a provided hashtable and a unified complete term. It assumes that the hashtable and the term argument contains only proper Term values (it does not perform any check towards this).
This constructor is not used in user application as well.

Parameters:
h - represents the hashtable that holds variable to term mappings.
uterm - represents the unified terms to be set as the result of a matching procedure.
Method Detail

put

public moses.controlState.Term put(java.lang.String var,
                                   moses.controlState.Term t)
Appends a new binding into the hashtable. Not used in user applications.

Parameters:
var - represents the name of the variable to be bound.
t - represents the term value to be bound to the variable
Returns:
the old binding for the same variable, if exists; null otherwise.

getTVar

public moses.controlState.Term getTVar(java.lang.String var)
Returns the term bound to the variable provided as argument. This method accepts as argument any variable name. If the name does not start with a VAR '%' character, then the prefix is afixed before the lookup takes place.

Parameters:
var - represents the name of the variable bound during the unification.
Returns:
the term corresponding to the variable provided as argument; null, if no such variable is found.

getSVar

public java.lang.String getSVar(java.lang.String var)
Returns the string representation of the term bound to variable var provided as argument. This method accepts as argument any variable name. If the name does not start with a VAR '%' character, then the prefix is set before the lookup takes place.

Parameters:
var - represents the name of the variable bound during the unification.
Returns:
the string representation of the term corresponding to the variable provided as argument; null, if no such variable is found.

getTerm

public moses.controlState.Term getTerm()
This method returns the complete term that has been unified. The result is ground, it does not have unbound variables.

Returns:
the complete term that has been unified.

setTerm

public void setTerm(moses.controlState.Term uterm)
This method sets the complete term that has been unified. It is internal method and not intended for user API.

Parameters:
uterm - represents the complete unified (ground) term.