org.opencyc.inferencesupport
Class BindingSet

java.lang.Object
  |
  +--org.opencyc.inferencesupport.BindingSet
All Implemented Interfaces:
java.lang.Comparable

public class BindingSet
extends java.lang.Object
implements java.lang.Comparable

BindingSet object to contain bindings for query literals.

Author:
Stephen L. Reed

Copyright 2001 Cycorp, Inc., license is open source GNU LGPL.

the license

www.opencyc.org

OpenCyc at SourceForge

THIS SOFTWARE AND KNOWLEDGE BASE CONTENT ARE PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENCYC ORGANIZATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE AND KNOWLEDGE BASE CONTENT, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


Field Summary
protected  java.util.ArrayList bindingValues
          The list of binding value lists associated with each variable, which is not used for cartesian product joins.
protected  java.util.ArrayList cartesianProductBindingSets
          The set of binding sets comprising a cartesian product join, which is not actually instantiatiated to save space.
protected  CycFort mt
          The microtheory in which the variable bindings were obtained
protected  QueryLiteral queryLiteral
          The literal for which these bindings were obtained.
 
Constructor Summary
BindingSet(QueryLiteral queryLiteral, CycFort mt)
          Constructs a new BindingSet object with the given QueryLiteral.
 
Method Summary
 void add(CycList bindingValueList)
          Adds a binding value list to the binding set.
 void addAll(java.util.ArrayList bindingValueLists)
          Adds a list of binding value lists to the binding set.
 int compareTo(java.lang.Object object)
          Compares this object with the specified object for order.
 void displayBindingSet()
          Displays the binding set.
 boolean equals(java.lang.Object object)
          Returns true if the object equals this object.
 java.util.ArrayList getBindingValues()
          Gets the binding values for this binding set.
 java.util.ArrayList getCartesianProductBindingSets()
          Returns the set of binding sets comprising a cartesian product join, which is not actually instantiatiated to save space.
 CycFort getMt()
          Returns the microtheory in which the variable bindings were obtained.
 int getNbrInstances()
          Gets the number of instances of this literal in the KB.
 QueryLiteral getQueryLiteral()
          Returns the literal for this binding set.
 java.util.ArrayList getVariables()
          Returns the variables in this binding set.
 boolean isBindingPostponed()
          Returns true iff the asking of the binding values has been postponed (due to the estimated number of KB instances exceeding a user-controlled threshold).
 boolean isCartesianProduct()
          Returns true iff the binding set has the form of an uninstantiated cartesian product.
 boolean isUnary()
          Returns true iff this is a formula having one variable.
 void setBindingValues(java.util.ArrayList bindingValues)
          Sets the binding values for this binding set.
 void setCartesianProductBindingSets(java.util.ArrayList cartesianProductBindingSets)
          Sets the set of binding sets comprising a cartesian product join.
 void setNbrInstances(int nbrFormulaInstances)
          Sets the number of instances of this literal in the KB.
 int size()
          Returns the size of the binding set for this literal.
 java.lang.String toString()
          Returns a String representation of the BindingSet object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

queryLiteral

protected QueryLiteral queryLiteral
The literal for which these bindings were obtained.

mt

protected CycFort mt
The microtheory in which the variable bindings were obtained

cartesianProductBindingSets

protected java.util.ArrayList cartesianProductBindingSets
The set of binding sets comprising a cartesian product join, which is not actually instantiatiated to save space.

bindingValues

protected java.util.ArrayList bindingValues
The list of binding value lists associated with each variable, which is not used for cartesian product joins.
Constructor Detail

BindingSet

public BindingSet(QueryLiteral queryLiteral,
                  CycFort mt)
           throws java.io.IOException,
                  CycApiException
Constructs a new BindingSet object with the given QueryLiteral.
Parameters:
queryLiteral - the literal for which bindings are obtained
mt - the microtheory in which the variable bindings are obtained
Method Detail

getQueryLiteral

public QueryLiteral getQueryLiteral()
Returns the literal for this binding set.
Returns:
the QueryLiteral for this binding set

getBindingValues

public java.util.ArrayList getBindingValues()
Gets the binding values for this binding set.
Returns:
the list of binding value lists associated with each variable,

setBindingValues

public void setBindingValues(java.util.ArrayList bindingValues)
Sets the binding values for this binding set.
Parameters:
bindingValues - the list of binding value lists associated with each variable,

add

public void add(CycList bindingValueList)
Adds a binding value list to the binding set.
Parameters:
bindingValueList - the list of values to be added to the binding set. The values are ordered to correspond with the order of the variables for this binding set's query literal.

addAll

public void addAll(java.util.ArrayList bindingValueLists)
Adds a list of binding value lists to the binding set.
Parameters:
bindingValueLists - the list of binding value lists to be added to the binding set

setNbrInstances

public void setNbrInstances(int nbrFormulaInstances)
Sets the number of instances of this literal in the KB.
Parameters:
nbrFormulaInstances - the number of instances of this literal in the KB

getNbrInstances

public int getNbrInstances()
Gets the number of instances of this literal in the KB.
Returns:
the number of instances matching this literal formula in the KB. Value of -1 indicates the variable is not yet set

isBindingPostponed

public boolean isBindingPostponed()
Returns true iff the asking of the binding values has been postponed (due to the estimated number of KB instances exceeding a user-controlled threshold).
Returns:
true iff the asking of the binding values has been postponed (due to the estimated number of KB instances exceeding a user-controlled threshold)

size

public int size()
Returns the size of the binding set for this literal.
Returns:
the size of the binding set for this literal

getVariables

public java.util.ArrayList getVariables()
Returns the variables in this binding set.
Returns:
the variables in this binding set

getMt

public CycFort getMt()
Returns the microtheory in which the variable bindings were obtained.
Returns:
the microtheory in which the variable bindings were obtained

displayBindingSet

public void displayBindingSet()
Displays the binding set.

equals

public boolean equals(java.lang.Object object)
Returns true if the object equals this object.
Overrides:
equals in class java.lang.Object
Parameters:
object - the object for comparison
Returns:
boolean indicating equality of an object with this object.

compareTo

public int compareTo(java.lang.Object object)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
Specified by:
compareTo in interface java.lang.Comparable
Parameters:
object - the reference object with which to compare.
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object

toString

public java.lang.String toString()
Returns a String representation of the BindingSet object.
Overrides:
toString in class java.lang.Object
Returns:
a String representation of the BindingSet object.

isUnary

public boolean isUnary()
Returns true iff this is a formula having one variable.
Returns:
true iff this is a formula having one variable

isCartesianProduct

public boolean isCartesianProduct()
Returns true iff the binding set has the form of an uninstantiated cartesian product.
Returns:
true iff the binding set has the form of an uninstantiated cartesian product

getCartesianProductBindingSets

public java.util.ArrayList getCartesianProductBindingSets()
Returns the set of binding sets comprising a cartesian product join, which is not actually instantiatiated to save space.
Returns:
the set of binding sets comprising a cartesian product join

setCartesianProductBindingSets

public void setCartesianProductBindingSets(java.util.ArrayList cartesianProductBindingSets)
Sets the set of binding sets comprising a cartesian product join.
Parameters:
cartesianProductBindingSets - the set of binding sets comprising a cartesian product join