org.semwebcentral.sweetrules.analyzer
Class SweetPDGBuilder

java.lang.Object
  extended byorg.semwebcentral.sweetrules.analyzer.SweetPDGBuilder

public final class SweetPDGBuilder
extends java.lang.Object

Created on Nov 8, 2004 The predicate dependency graph builder TODO: Task: Change the object array representation to a "struct" based representation Details: A predicate with a sign is represented as a 2 element object array which is accessed internally. The first element a boolean value indicating the type of dependency, i.e e.g. 1) p1 :- fneg q1 2) cneg p2 : q2 In case 1), p1 will have a subgoal with -ve dependency as q1 case 2), q2 will have a supergoal with -ve dependency as p2 so, while building the PDG, these will be passed around as (false, q1) and (false, p2) while building the PDG nodes corresponding to p1 and q2 respectively. For convienience getPredicatesWithoutDependencySign methods are provided to get rid of the dependency sign and list only the predicates either in the head or the body. These API are extremely useful while assigning salience in translation to Jess. Using a "struct" representation would be more natural.

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

Field Summary
private static SweetPDGBuilder pdgBuilder
          The singleton object
 
Constructor Summary
private SweetPDGBuilder()
          Hidden constructor
 
Method Summary
private  void addAllAfterRemovingDependencySign(java.util.Vector predicatesWithDepSign, java.util.Vector predicatesWithoutDep)
          Strips off the dependency sign and returns only the predicates
 void buildPDG(org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.ImpType imp, SweetPredicateDependencyGraph pdg)
           
 void buildPDG(org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.RulebaseType rb, SweetPredicateDependencyGraph pdg)
           
private  void getBodyPredicatesFromList(java.util.List bodyList, java.util.Vector predicateVector)
           
static SweetPDGBuilder getInstance()
          Accessor method for the singleton object
private  SweetPredicate getPredicateFromObjectArray(java.lang.Object[] predicateObject)
          Decouples a predicate from the object composed above
private  java.lang.Boolean getPredicateSignFromObjectArray(java.lang.Object[] predicateObject)
          Gets the sign from the object array
private  void getPredicatesWithDependencySign(org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.AndbType andbElement, java.util.Vector predicateVector)
           
private  void getPredicatesWithDependencySign(org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.AndhType andh, java.util.Vector predicateVector)
           
private  void getPredicatesWithDependencySign(org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.AndType andElement, java.util.Vector predicateVector)
           
private  void getPredicatesWithDependencySign(org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.AtomType atom, java.util.Vector predicateVector)
           
private  void getPredicatesWithDependencySign(org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.BodyType body, java.util.Vector predicateVector)
           
private  void getPredicatesWithDependencySign(org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.CslitType cslit, java.util.Vector predicateVector)
           
private  void getPredicatesWithDependencySign(org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.FclitType fclit, java.util.Vector predicateVector)
           
private  void getPredicatesWithDependencySign(org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.HeadType head, java.util.Vector predicateVector)
           
private  void getPredicatesWithDependencySign(org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.OrbType orbElement, java.util.Vector predicateVector)
           
 void getPredicatesWithoutDependencySign(org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.BodyType body, java.util.Vector predicateVector)
          Strips off the dependency sign and returns only the predicates
 void getPredicatesWithoutDependencySign(org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.HeadType head, java.util.Vector predicateVector)
          Strips off the dependency sign and returns only the predicate
private  java.lang.Object[] getPredicateWithDependencySign(SweetPredicate predicate, boolean dependencySign)
          Returns an "augmented" predicate i.e an array of 2 objects the first being boolean indicating the type of dependency (i.e -ve or +ve) and the second being the predicate itself
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pdgBuilder

private static SweetPDGBuilder pdgBuilder
The singleton object

Constructor Detail

SweetPDGBuilder

private SweetPDGBuilder()
Hidden constructor

Method Detail

getInstance

public static SweetPDGBuilder getInstance()
Accessor method for the singleton object

Returns:
The singleton object

buildPDG

public void buildPDG(org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.RulebaseType rb,
                     SweetPredicateDependencyGraph pdg)

buildPDG

public void buildPDG(org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.ImpType imp,
                     SweetPredicateDependencyGraph pdg)

getPredicatesWithoutDependencySign

public void getPredicatesWithoutDependencySign(org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.BodyType body,
                                               java.util.Vector predicateVector)
Strips off the dependency sign and returns only the predicates

Parameters:
body - The body to process
predicateVector - The predicateVector to store the result

addAllAfterRemovingDependencySign

private void addAllAfterRemovingDependencySign(java.util.Vector predicatesWithDepSign,
                                               java.util.Vector predicatesWithoutDep)
Strips off the dependency sign and returns only the predicates

Parameters:
predicatesWithDepSign - The vector with the dependency sign to process

getPredicatesWithDependencySign

private void getPredicatesWithDependencySign(org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.BodyType body,
                                             java.util.Vector predicateVector)

getPredicatesWithDependencySign

private void getPredicatesWithDependencySign(org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.AndType andElement,
                                             java.util.Vector predicateVector)

getPredicatesWithDependencySign

private void getPredicatesWithDependencySign(org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.AndbType andbElement,
                                             java.util.Vector predicateVector)

getPredicatesWithDependencySign

private void getPredicatesWithDependencySign(org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.OrbType orbElement,
                                             java.util.Vector predicateVector)

getBodyPredicatesFromList

private void getBodyPredicatesFromList(java.util.List bodyList,
                                       java.util.Vector predicateVector)

getPredicatesWithoutDependencySign

public void getPredicatesWithoutDependencySign(org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.HeadType head,
                                               java.util.Vector predicateVector)
Strips off the dependency sign and returns only the predicate

Parameters:
head - The head to process
predicateVector - The predicateVector to store the result

getPredicatesWithDependencySign

private void getPredicatesWithDependencySign(org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.HeadType head,
                                             java.util.Vector predicateVector)

getPredicatesWithDependencySign

private void getPredicatesWithDependencySign(org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.AndhType andh,
                                             java.util.Vector predicateVector)

getPredicatesWithDependencySign

private void getPredicatesWithDependencySign(org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.CslitType cslit,
                                             java.util.Vector predicateVector)

getPredicatesWithDependencySign

private void getPredicatesWithDependencySign(org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.AtomType atom,
                                             java.util.Vector predicateVector)

getPredicatesWithDependencySign

private void getPredicatesWithDependencySign(org.semwebcentral.sweetrules.ruleml.sweetrulemlobjectmodel.FclitType fclit,
                                             java.util.Vector predicateVector)

getPredicateWithDependencySign

private java.lang.Object[] getPredicateWithDependencySign(SweetPredicate predicate,
                                                          boolean dependencySign)
Returns an "augmented" predicate i.e an array of 2 objects the first being boolean indicating the type of dependency (i.e -ve or +ve) and the second being the predicate itself

Parameters:
predicate - The predicate
dependencySign - The dependency sign of the predicate
Returns:
The composed object with both the predicate and the sign

getPredicateFromObjectArray

private SweetPredicate getPredicateFromObjectArray(java.lang.Object[] predicateObject)
Decouples a predicate from the object composed above

Parameters:
predicateObject - The predicate object
Returns:
The predicate

getPredicateSignFromObjectArray

private java.lang.Boolean getPredicateSignFromObjectArray(java.lang.Object[] predicateObject)
Gets the sign from the object array

Parameters:
predicateObject - The predicate object
Returns:
The sign of the dependency of the predicate