edu.lehigh.swat.obione
Class LAVProcessor

java.lang.Object
  extended by edu.lehigh.swat.obione.KAON2AbstractConnection
      extended by edu.lehigh.swat.obione.LAVProcessor

public class LAVProcessor
extends KAON2AbstractConnection

LAV processor implelements the Minicon in to Semantic Web

Author:
abirqasem

Field Summary
private static int nextMCDId
           
private  OBI1Query theQry
           
private  boolean verbose
           
private  java.util.Vector<Rewrite> viewHeadRewrites
           
 
Fields inherited from class edu.lehigh.swat.obione.KAON2AbstractConnection
m_connection
 
Constructor Summary
LAVProcessor()
           
 
Method Summary
 MiniConDescription attemptMCD(org.semanticweb.kaon2.api.rules.Literal qs, LegacySourceView v)
           
 java.util.Vector[] combineMCDs(java.util.Vector<java.util.BitSet> mcd)
          A wrapper around the doRewrite of MCDFromBitSet
private  org.semanticweb.kaon2.api.rules.Literal convertLitCandidate(java.lang.String litcan)
           
 java.util.Vector<Rewrite> decompose(org.semanticweb.kaon2.api.reasoner.Query sprqlQ, LegacySourceView[] r)
          Entry point to the LAV reformulation.
 java.util.ArrayList<MiniConDescription> decompose(java.util.Vector<Node> gns, org.semanticweb.kaon2.api.rules.Rule r)
          Entry point to the LAV reformulation from PDMS Generates the MCDs, combines them to find the covering MCDs and then finally gets all the rewrites (this may change, we may return something that is more convi nient
private  boolean distinguished(org.semanticweb.kaon2.api.rules.Variable v, org.semanticweb.kaon2.api.rules.Rule r)
          Helper - checks if a variable is distinguished or not
 MiniConDescription extendSubgoals(org.semanticweb.kaon2.api.rules.Variable existVar, org.semanticweb.kaon2.api.rules.Literal qs, java.util.HashMap varmap, java.util.HashMap hm, LegacySourceView sv)
           
 java.util.ArrayList<MiniConDescription> generateMCDs(LegacySourceView[] views)
           
(package private)  java.util.Vector<Rewrite> getAllRewrites(java.util.Vector[] paths, java.util.ArrayList<MiniConDescription> mcds)
          Generates the rewrites once we have found all the paths through out Bitset implementation
 java.util.Vector<Rewrite> getSpecialRewrites()
          gets all the "special rewrites
 OBI1Query getTheQuery()
           
private  java.util.List<org.semanticweb.kaon2.api.rules.Variable> getVariables(org.semanticweb.kaon2.api.rules.Rule r)
          Helper function
private  void initHomomorphism(java.util.Map hmap, LegacySourceView view)
          Intialize the homomorphism to identity by mapping all variables in the rule to themselves
private  boolean isIn(MiniConDescription mcd, java.util.ArrayList<MiniConDescription> mcds)
          Helper method to check if an MCD is already in the array list.
static void main(java.lang.String[] args)
           
 LegacySourceView[] parseInput(java.lang.String filename)
           
 boolean predMatch(org.semanticweb.kaon2.api.rules.Literal queryGoal, org.semanticweb.kaon2.api.rules.Literal viewGoal, java.util.HashMap hmapIn, java.util.HashMap varmapIn)
          Matches a query literal with a view literal, extending the head homomorphism and the variable map in the process.
(package private)  void printRule(org.semanticweb.kaon2.api.rules.Rule r)
           
 
Methods inherited from class edu.lehigh.swat.obione.KAON2AbstractConnection
createOntology, endConnection, loadOntology, makeConnection, showOntologyAxioms, showOntologyEntities
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

theQry

private OBI1Query theQry

viewHeadRewrites

private java.util.Vector<Rewrite> viewHeadRewrites

nextMCDId

private static int nextMCDId

verbose

private boolean verbose
Constructor Detail

LAVProcessor

public LAVProcessor()
Method Detail

getSpecialRewrites

public java.util.Vector<Rewrite> getSpecialRewrites()
gets all the "special rewrites

Returns:

getAllRewrites

java.util.Vector<Rewrite> getAllRewrites(java.util.Vector[] paths,
                                         java.util.ArrayList<MiniConDescription> mcds)
Generates the rewrites once we have found all the paths through out Bitset implementation

Parameters:
paths -
mcds -
Returns:

decompose

public java.util.ArrayList<MiniConDescription> decompose(java.util.Vector<Node> gns,
                                                         org.semanticweb.kaon2.api.rules.Rule r)
Entry point to the LAV reformulation from PDMS Generates the MCDs, combines them to find the covering MCDs and then finally gets all the rewrites (this may change, we may return something that is more convi nient

Parameters:
sprqlQ -
r -
Returns:

decompose

public java.util.Vector<Rewrite> decompose(org.semanticweb.kaon2.api.reasoner.Query sprqlQ,
                                           LegacySourceView[] r)
Entry point to the LAV reformulation. Generates the MCDs, combines them to find the covering MCDs and then finally gets all the rewrites

Parameters:
sprqlQ -
r -
Returns:

combineMCDs

public java.util.Vector[] combineMCDs(java.util.Vector<java.util.BitSet> mcd)
A wrapper around the doRewrite of MCDFromBitSet

Parameters:
mcd -
Returns:

generateMCDs

public java.util.ArrayList<MiniConDescription> generateMCDs(LegacySourceView[] views)
Parameters:
dlp - Gernerates Minicon for a query given a set of source views

main

public static void main(java.lang.String[] args)

parseInput

public LegacySourceView[] parseInput(java.lang.String filename)
Parameters:
filename - parses a text file (assuming no formatting error) in to an array of KAON2 rules Two issues a) We assume the first rule to be the CQ. It is read in as a rule because CQ is a rule, but it may have to be translated later to be compatible with KAON2 query b) array of rules is a quick and dirty implemenation of the DLP. This needs to be fixed

isIn

private boolean isIn(MiniConDescription mcd,
                     java.util.ArrayList<MiniConDescription> mcds)
Helper method to check if an MCD is already in the array list. contains does not seem to work in Mac for Java


attemptMCD

public MiniConDescription attemptMCD(org.semanticweb.kaon2.api.rules.Literal qs,
                                     LegacySourceView v)
Parameters:
qs -
v - uses the 4 cases to create an MCD from a query subgoal and a view

extendSubgoals

public MiniConDescription extendSubgoals(org.semanticweb.kaon2.api.rules.Variable existVar,
                                         org.semanticweb.kaon2.api.rules.Literal qs,
                                         java.util.HashMap varmap,
                                         java.util.HashMap hm,
                                         LegacySourceView sv)

getTheQuery

public OBI1Query getTheQuery()

predMatch

public boolean predMatch(org.semanticweb.kaon2.api.rules.Literal queryGoal,
                         org.semanticweb.kaon2.api.rules.Literal viewGoal,
                         java.util.HashMap hmapIn,
                         java.util.HashMap varmapIn)
Matches a query literal with a view literal, extending the head homomorphism and the variable map in the process. Assumes that hm is initial set to identity for all variables in the view and that var map is an empty map. Note, the key of the maps should be variables, but the content can be other kinds of terms. Note: there might be some problems with backtracking if we're not careful


getVariables

private java.util.List<org.semanticweb.kaon2.api.rules.Variable> getVariables(org.semanticweb.kaon2.api.rules.Rule r)
Helper function

Parameters:
r -
Returns:

initHomomorphism

private void initHomomorphism(java.util.Map hmap,
                              LegacySourceView view)
Intialize the homomorphism to identity by mapping all variables in the rule to themselves

Parameters:
hmap - A Map representing the homomophism
r - A KAON rule representing the view

printRule

void printRule(org.semanticweb.kaon2.api.rules.Rule r)
Parameters:
r - A debug utilty to print rules

distinguished

private boolean distinguished(org.semanticweb.kaon2.api.rules.Variable v,
                              org.semanticweb.kaon2.api.rules.Rule r)
Helper - checks if a variable is distinguished or not

Parameters:
v -
r -
Returns:

convertLitCandidate

private org.semanticweb.kaon2.api.rules.Literal convertLitCandidate(java.lang.String litcan)
Parameters:
litcan - Creates a KAON2 Literal from string parsed from the data.in file