org.semwebcentral.sweetrules.sweetxsb
Class SweetRuleMLQueryXSBAdapterTask

java.lang.Object
  extended byorg.semwebcentral.sweetrules.sweetxsb.AbstractSweetXSBQueryAdapterTask
      extended byorg.semwebcentral.sweetrules.sweetxsb.SweetRuleMLQueryXSBAdapterTask
All Implemented Interfaces:
ISweetInferenceEngineTask

public class SweetRuleMLQueryXSBAdapterTask
extends AbstractSweetXSBQueryAdapterTask
implements ISweetInferenceEngineTask


The class which performs the required workarounds for processing a ruleml query in XSB

Modified on: Aug 25, 2004, 2:07:59 PM

Author:
Shashidhara K Ganjugunte, Dr. Benjamin Grosof, Dr. Said Tabet, Chitravanu Neogy

Field Summary
private static Logger logger
          This represents the logger object
private  java.lang.String queryString
          The query string
private  ISweetTranslator ruleML2XSBTranslator
          The ruleml to xsb translator
private  java.lang.String transformXSLFileURL
          The URL of the XSLT sheet to perform translation
 
Fields inherited from class org.semwebcentral.sweetrules.sweetxsb.AbstractSweetXSBQueryAdapterTask
sweetDisambigDummyPredicatePrefix, sweetDummyPredicateName, xsbEngine
 
Constructor Summary
SweetRuleMLQueryXSBAdapterTask(java.lang.String ruleMLQuery, ISweetTranslator ruleML2XSBTranslator, java.lang.String dummyPredicateName, java.lang.String disambigDummyPredicatePrefix, SweetXSBEngine engine)
          Constructor for the RuleML query
 
Method Summary
protected  java.lang.String[] applyAllSubstitutions(java.lang.String query, java.util.Vector varNameVector, java.util.Vector answerBindingMatrix)
          Provides an abstraction of applying substitutions
private  ISweetQueryResult createGoalAndExecuteQuery(java.lang.String ruleMLQuery)
          Creates the goal in the XSB form and executes the query
 java.lang.Object execute()
          Implementation of execute for a ruleml query
protected  java.lang.String[] generateBindingList(java.util.Vector varNameVector, java.util.Vector answerBindingMatrix)
          Provides the abstraction of generating the binding list
private  java.lang.String generateCanonicalRuleMLQuery(java.lang.String ruleMLQuery)
          Method to generate the canonical form (head :- body) of a ruleml query
private  void translateAndLoadQuery(java.lang.String canonicalRuleML)
          Method to translate the canonical ruleml to XSB (using r2xsb translator) and load the query to the XSB engine
 
Methods inherited from class org.semwebcentral.sweetrules.sweetxsb.AbstractSweetXSBQueryAdapterTask
executeAbolishDummyPredicates, flattenAndDetectNonGroundTerms, generateQueryResultForGroundQuery, generateQueryResultForNonGroundQuery, generateTermModelAnswerSets, getEntailedAnswerSetMatrix, processSingleBinding, pruneAndgetUndefinedAnswerSetMatrix
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ruleML2XSBTranslator

private ISweetTranslator ruleML2XSBTranslator
The ruleml to xsb translator


queryString

private java.lang.String queryString
The query string


transformXSLFileURL

private java.lang.String transformXSLFileURL
The URL of the XSLT sheet to perform translation


logger

private static Logger logger
This represents the logger object

Constructor Detail

SweetRuleMLQueryXSBAdapterTask

public SweetRuleMLQueryXSBAdapterTask(java.lang.String ruleMLQuery,
                                      ISweetTranslator ruleML2XSBTranslator,
                                      java.lang.String dummyPredicateName,
                                      java.lang.String disambigDummyPredicatePrefix,
                                      SweetXSBEngine engine)
Constructor for the RuleML query

Parameters:
ruleMLQuery - The ruleML query
ruleML2XSBTranslator - The translator which can translate from ruleml to xsb
dummyPredicateName - A name which will be used temporarily to query XSB NOTE: This predicate name should **NOT** cause conflicts
engine - The SweetXSBEngine to execute the query on
Method Detail

execute

public java.lang.Object execute()
                         throws SweetInferenceEngineException
Implementation of execute for a ruleml query

Specified by:
execute in interface ISweetInferenceEngineTask
Returns:
The result of execution of the query
Throws:
SweetInferenceEngineException

generateCanonicalRuleMLQuery

private java.lang.String generateCanonicalRuleMLQuery(java.lang.String ruleMLQuery)
                                               throws SweetInferenceEngineException
Method to generate the canonical form (head :- body) of a ruleml query

Parameters:
ruleMLQuery - The input query in RuleML
Returns:
The transformed query
Throws:
InfernceEngineException - if an error occurs
SweetInferenceEngineException

translateAndLoadQuery

private void translateAndLoadQuery(java.lang.String canonicalRuleML)
                            throws SweetInferenceEngineException
Method to translate the canonical ruleml to XSB (using r2xsb translator) and load the query to the XSB engine

Parameters:
canonicalRuleML - The transformed RuleML query
Throws:
SweetInferenceEngineException - if an error occurs

createGoalAndExecuteQuery

private ISweetQueryResult createGoalAndExecuteQuery(java.lang.String ruleMLQuery)
                                             throws SweetInferenceEngineException
Creates the goal in the XSB form and executes the query

Parameters:
ruleMLQuery - The ruleML query
Returns:
The answer set to the query
Throws:
SweetInferenceEngineException - if an error occurs

applyAllSubstitutions

protected java.lang.String[] applyAllSubstitutions(java.lang.String query,
                                                   java.util.Vector varNameVector,
                                                   java.util.Vector answerBindingMatrix)
                                            throws SweetInferenceEngineException
Provides an abstraction of applying substitutions

Specified by:
applyAllSubstitutions in class AbstractSweetXSBQueryAdapterTask
Parameters:
query - The query on which substitutions need to be applied
varNameVector - The vector of the variables
answerBindingMatrix - The matrix having the bindings of the variables
Returns:
An array of strings after applying all substitutions
Throws:
SweetInferenceEngineException - if an error occurs

generateBindingList

protected java.lang.String[] generateBindingList(java.util.Vector varNameVector,
                                                 java.util.Vector answerBindingMatrix)
                                          throws SweetInferenceEngineException
Provides the abstraction of generating the binding list

Specified by:
generateBindingList in class AbstractSweetXSBQueryAdapterTask
Parameters:
varNameVector - The vector of variables
answerBindingMatrix - The values of the variables in the form of an answer binding list
Returns:
An array of Strings having the result of the application of bindings
Throws:
SweetInferenceEngineException