public class Rule
extends java.lang.Object
| Constructor and Description |
|---|
Rule()
Instantiates an empty rule.
|
Rule(javatools.datatypes.ByteString[] headAtom,
double cardinality)
Instantiates a rule of the form [] => r(?a, ?b) with empty body
and the given pattern as rule.
|
Rule(javatools.datatypes.ByteString[] head,
java.util.List<javatools.datatypes.ByteString[]> body,
double cardinality) |
Rule(Rule otherQuery,
double support)
Creates a new query as a clone of the query sent as argument with the given
support.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
_containsQuasiBindings() |
boolean |
_isBelowMinimumSupport() |
void |
_setBelowMinimumSupport(boolean belowMinimumSupport) |
void |
_setContainsQuasibinding(boolean containsQuasiBindings) |
Rule |
addAtom(javatools.datatypes.ByteString[] newAtom,
double cardinality) |
Rule |
addAtom(javatools.datatypes.ByteString[] newAtom,
int cardinality,
javatools.datatypes.ByteString joinedVariable,
javatools.datatypes.ByteString danglingVariable)
Returns a new rule that contains all the atoms of the current rule plus
the atom provided as argument.
|
Rule |
addEdges(javatools.datatypes.ByteString[] newEdge1,
javatools.datatypes.ByteString[] newEdge2)
Returns a new rule that is a copy of the current rules plus the two edges
sent as arguments.
|
int |
alternativeParentHashCode()
The alternative hash code for the parents of the rule.
|
static boolean |
areEquivalent(javatools.datatypes.ByteString[] pattern,
javatools.datatypes.ByteString[] newAtom) |
static void |
bind(javatools.datatypes.ByteString oldVal,
javatools.datatypes.ByteString newVal,
java.util.List<javatools.datatypes.ByteString[]> query)
Replaces all occurrences of oldVal with newVal in the subject and object
positions of the input query.
|
static void |
bind(java.util.Map<javatools.datatypes.ByteString,javatools.datatypes.ByteString> mappings,
java.util.List<javatools.datatypes.ByteString[]> inputTriples)
Applies the mappings provided as first argument to the subject and object
positions of the query included in the second argument.
|
int |
cardinalityForRelation(javatools.datatypes.ByteString relation)
Returns the number of times the relation occurs in the atoms of the query
|
static Rule |
combineRules(java.util.List<Rule> rules)
Given a list of rules A1 => X1, ...
|
boolean |
containsDisallowedDiamond() |
boolean |
containsLevel2RedundantSubgraphs()
For rules with an even number of atoms (n > 2), it checks if it contains
level 2 redundant subgraphs, that is, each relation occurs exactly twice
in the rule.
|
boolean |
containsRelation(javatools.datatypes.ByteString relation) |
int |
containsRelationTimes(javatools.datatypes.ByteString relation) |
boolean |
containsRepeatedVariablesInLastPattern()
Determines if a pattern contains repeated components, which are
considered hard to satisfy (i.e., ?x somePredicate ?x)
|
boolean |
containsSinglePath()
It determines whether the rule contains a single path that connects the
head variables in the body.
|
boolean |
containsUnifiablePatterns()
Determines whether the last atom of the query.
|
static boolean |
equal(javatools.datatypes.ByteString[] pattern1,
javatools.datatypes.ByteString[] pattern2) |
static boolean |
equals(javatools.datatypes.ByteString[] atom1,
javatools.datatypes.ByteString[] atom2) |
boolean |
equals(java.lang.Object obj) |
static int |
findFunctionalVariable(Rule q,
KB d) |
javatools.datatypes.ByteString[] |
fullyUnboundTriplePattern()
It creates a new unbound atom with fresh variables for the subject and object
and an undefined property, i.e., ?s[n] ?p ?o[n].
|
static javatools.datatypes.ByteString[] |
fullyUnboundTriplePattern1()
It creates a new unbound atom with fresh variables for the subject and object
and an undefined property, i.e., ?s[n] ?p ?o[n].
|
java.util.List<Rule> |
getAllAncestors() |
java.util.List<Rule> |
getAncestors() |
java.util.List<javatools.datatypes.ByteString[]> |
getAntecedent()
Returns the list of triples in the body of the rule.
|
java.util.List<javatools.datatypes.ByteString[]> |
getAntecedentClone()
Returns a list with copies of the triples of the rule.
|
java.lang.String |
getBasicRuleString() |
java.util.List<javatools.datatypes.ByteString[]> |
getBody()
Returns the list of triples in the body of the rule.
|
long |
getBodyMinusHeadSize() |
java.util.List<javatools.datatypes.ByteString> |
getBodyRelations() |
long |
getBodySize()
The support of the body of the rule.
|
java.util.Set<javatools.datatypes.ByteString> |
getBodyVariables()
Returns an array with the variables that occur in the body but not in the
head.
|
java.util.List<javatools.datatypes.ByteString[]> |
getCanonicalPath()
Given a rule that contains a single variables path for the head variables
in the body (the method containsSinglePath returns true), it returns the
atoms sorted so that the path can be reproduced.
|
double |
getConfidenceRunningTime() |
java.lang.String |
getDatalogString() |
int[] |
getEvaluationResult() |
java.lang.String |
getFullRuleString() |
javatools.datatypes.ByteString |
getFunctionalVariable() |
int |
getFunctionalVariablePosition() |
long |
getHashCardinality()
The cardinality number used to hash the rule.
|
javatools.datatypes.ByteString[] |
getHead()
Returns the head of a query B => r(a, b) as a triple [?a, r, ?b].
|
double |
getHeadCoverage() |
java.lang.String |
getHeadKey()
Return a key for the rule based on the constant arguments of the head
atom.
|
java.lang.String |
getHeadRelation()
Returns the rule's head relation as a String
|
javatools.datatypes.ByteString |
getHeadRelationBS()
Returns the rule's head relation as ByteString.
|
java.util.List<javatools.datatypes.ByteString> |
getHeadVariables()
Returns the head variables of the rule.
|
int |
getId() |
javatools.datatypes.ByteString[] |
getLastRealTriplePattern()
Return the last triple pattern which is not the a pseudo-atom.
|
int |
getLastRealTriplePatternIndex()
Return the index of the last triple pattern which is not the a
pseudo-atom.
|
javatools.datatypes.ByteString[] |
getLastTriplePattern()
Returns the last triple pattern added to this rule.
|
int |
getLength()
Returns the number of atoms of the rule.
|
int |
getLengthWithoutTypes(javatools.datatypes.ByteString typeString)
Returns the number of atoms of the rule that are not type constraints of
the form rdf:type(?x, C) where C is a class, i.e., Person.
|
int |
getLengthWithoutTypesAndLinksTo(javatools.datatypes.ByteString typeString,
javatools.datatypes.ByteString linksString)
Returns the number of atoms of the rule that are neither type constraints
of the form rdf:type(?x, C) or linksTo atoms.
|
javatools.datatypes.ByteString |
getNonFunctionalVariable() |
int |
getNonFunctionalVariablePosition() |
java.util.List<javatools.datatypes.ByteString> |
getOpenVariables() |
static void |
getParentsOfSize(java.util.List<javatools.datatypes.ByteString[]> antecedent,
javatools.datatypes.ByteString[] head,
int windowSize,
java.util.List<java.util.List<javatools.datatypes.ByteString[]>> output)
Given the antecedent and the succedent of a rule as sets of atoms, it
returns the combinations of atoms of size 'i' that are "parents" of the
current rule, i.e., subsets of atoms of the original rule.
|
double |
getPcaBodySize() |
double |
getPcaConfidence() |
double |
getPcaConfidenceRunningTime() |
double |
getPcaEstimation() |
java.util.List<javatools.datatypes.ByteString[]> |
getPCAQuery()
It returns the query expression corresponding to the normalization value
used to calculate the PCA confidence.
|
int |
getRealLength()
Returns the number of atoms of the rule that are not pseudo-atoms
Pseudo-atoms contain the Database keywords "DIFFERENTFROM" and "EQUALS"
|
int |
getRealLengthWithoutTypes(javatools.datatypes.ByteString typeString)
Returns the number of atoms of the rule that are neither pseudo-atoms nor
type constraints.
|
java.util.List<javatools.datatypes.ByteString[]> |
getRealTriples()
Returns the triples of a query except for those containing DIFFERENTFROM
constraints.
|
java.util.List<javatools.datatypes.ByteString[]> |
getRedundantAtoms()
Checks whether the last atom in the query is redundant.
|
java.util.List<javatools.datatypes.ByteString[]> |
getRedundantAtoms(int withRespectToIdx)
Look for the redundant atoms with respect to a reference atom
|
java.lang.String |
getRuleString() |
double |
getStdConfidence() |
javatools.datatypes.ByteString[] |
getSuccedent()
Returns the head of a query B => r(a, b) as a triple [?a, r, ?b].
|
double |
getSupport() |
double |
getSupportRatio() |
java.util.List<javatools.datatypes.ByteString[]> |
getTriples()
Return the list of triples of the query.
|
java.util.List<javatools.datatypes.ByteString> |
getVariables()
Returns a list with all the different variables in the query.
|
boolean |
hasConfidenceGain()
Verifies if the given rule has higher confidence that its parent rules.
|
int |
hashCode() |
Rule |
instantiateConstant(int danglingPosition,
javatools.datatypes.ByteString constant,
double cardinality)
Returns a new query where the variable at the dangling position of the
last atom has been unified to the provided constant.
|
Rule |
instantiateConstant(int triplePos,
int danglingPosition,
javatools.datatypes.ByteString constant,
double cardinality)
Return a new query where the variable at position danglingPosition in
triple at position triplePos is bound to constant.
|
boolean |
isClosed() |
boolean |
isEmpty() |
static boolean |
isGroundAtom(javatools.datatypes.ByteString[] pattern)
Returns true if the triple pattern contains constants in all its
positions
|
boolean |
isPerfect() |
boolean |
isRedundantRecursive()
Returns true if the rule contains redundant recursive atoms, i.e., atoms
with a relation that occurs more than once AND that do not have any
effect on the query result.
|
static boolean |
isUnifiable(javatools.datatypes.ByteString[] pattern,
javatools.datatypes.ByteString[] newAtom)
Determines if the second argument is unifiable to the first one.
|
static int[] |
joinPositions(javatools.datatypes.ByteString[] a1,
javatools.datatypes.ByteString[] a2)
Given 2 atoms joining in at least one variable, it returns the first
pairs of variable positions of each atom.
|
static void |
main(java.lang.String[] args) |
static void |
printRuleBasicHeaders() |
static void |
printRuleHeaders() |
static java.util.List<javatools.datatypes.ByteString[]> |
redundantAtoms(javatools.datatypes.ByteString[] test,
java.util.List<javatools.datatypes.ByteString[]> query)
It returns a list with all the redundant atoms contained in the first
list, i.e., atoms whose removal does not affect the results of the query
defined in the second list.
|
Rule |
rewriteQuery(javatools.datatypes.ByteString[] remove,
javatools.datatypes.ByteString[] target,
javatools.datatypes.ByteString victimVar,
javatools.datatypes.ByteString targetVar) |
void |
setBodyMinusHeadSize(int size) |
void |
setBodySize(long bodySize) |
void |
setConfidenceRunningTime(double confidenceRunningTime) |
void |
setConfidenceUpperBound(double stdConfUpperBound) |
void |
setEvaluationResult(int[] evaluationResult) |
void |
setFunctionalVariablePosition(int functionalVariablePosition) |
void |
setHeadCoverage(double headCoverage) |
void |
setId(int id) |
void |
setParent(Rule parent)
Sets the rule's parent rule.
|
void |
setPcaBodySize(double size) |
void |
setPcaConfidenceRunningTime(double pcaConfidenceRunningTime) |
void |
setPcaConfidenceUpperBound(double pcaConfUpperBound) |
void |
setPcaEstimation(double pcaEstimation) |
void |
setSupport(double cardinality) |
void |
setSupportRatio(double support) |
protected void |
setTriples(java.util.ArrayList<javatools.datatypes.ByteString[]> triples) |
static java.lang.String |
toDatalog(javatools.datatypes.ByteString[] atom) |
java.lang.String |
toString()
Simple string representation of the rule.
|
static javatools.datatypes.ByteString[] |
triple(javatools.datatypes.ByteString sub,
javatools.datatypes.ByteString pred,
javatools.datatypes.ByteString obj)
It puts the arguments in an array.
|
static boolean |
unifies(javatools.datatypes.ByteString[] test,
java.util.List<javatools.datatypes.ByteString[]> query) |
boolean |
variableCanBeDeleted(int triplePos,
int varPos) |
public Rule()
public Rule(javatools.datatypes.ByteString[] headAtom,
double cardinality)
headAtom - The head atom as an array of the form [?a, r, ?b].cardinality - public Rule(Rule otherQuery, double support)
otherQuery - support - public Rule(javatools.datatypes.ByteString[] head,
java.util.List<javatools.datatypes.ByteString[]> body,
double cardinality)
public static javatools.datatypes.ByteString[] triple(javatools.datatypes.ByteString sub,
javatools.datatypes.ByteString pred,
javatools.datatypes.ByteString obj)
sub - pred - obj - public static boolean equal(javatools.datatypes.ByteString[] pattern1,
javatools.datatypes.ByteString[] pattern2)
public javatools.datatypes.ByteString[] fullyUnboundTriplePattern()
public static javatools.datatypes.ByteString[] fullyUnboundTriplePattern1()
public static boolean equals(javatools.datatypes.ByteString[] atom1,
javatools.datatypes.ByteString[] atom2)
public java.util.List<javatools.datatypes.ByteString[]> getTriples()
public java.util.List<javatools.datatypes.ByteString[]> getRealTriples()
public javatools.datatypes.ByteString[] getHead()
public javatools.datatypes.ByteString[] getSuccedent()
public java.util.List<javatools.datatypes.ByteString[]> getBody()
public java.util.List<javatools.datatypes.ByteString[]> getAntecedent()
public java.util.List<javatools.datatypes.ByteString[]> getAntecedentClone()
protected void setTriples(java.util.ArrayList<javatools.datatypes.ByteString[]> triples)
public java.util.List<javatools.datatypes.ByteString> getOpenVariables()
public double getHeadCoverage()
public void setHeadCoverage(double headCoverage)
public double getSupportRatio()
public void setSupportRatio(double support)
support - the support to setpublic double getSupport()
public long getHashCardinality()
public void setSupport(double cardinality)
cardinality - the headBodyCount to setpublic long getBodySize()
public void setBodySize(long bodySize)
bodySize - public double getStdConfidence()
public int[] getEvaluationResult()
public void setEvaluationResult(int[] evaluationResult)
evaluationResult - the evaluationResult to setpublic double getPcaConfidence()
public double getConfidenceRunningTime()
public void setConfidenceRunningTime(double confidenceRunningTime)
public double getPcaConfidenceRunningTime()
public void setPcaConfidenceRunningTime(double pcaConfidenceRunningTime)
public int getId()
public void setId(int id)
public javatools.datatypes.ByteString[] getLastTriplePattern()
public javatools.datatypes.ByteString[] getLastRealTriplePattern()
public int getLastRealTriplePatternIndex()
public int cardinalityForRelation(javatools.datatypes.ByteString relation)
public static boolean isGroundAtom(javatools.datatypes.ByteString[] pattern)
pattern - public java.util.List<javatools.datatypes.ByteString[]> getRedundantAtoms(int withRespectToIdx)
withRespectToIdx - The index of the reference atompublic java.util.List<javatools.datatypes.ByteString[]> getRedundantAtoms()
public javatools.datatypes.ByteString getFunctionalVariable()
public javatools.datatypes.ByteString getNonFunctionalVariable()
public int getFunctionalVariablePosition()
public void setFunctionalVariablePosition(int functionalVariablePosition)
public int getNonFunctionalVariablePosition()
public static boolean isUnifiable(javatools.datatypes.ByteString[] pattern,
javatools.datatypes.ByteString[] newAtom)
pattern - newAtom - public static boolean areEquivalent(javatools.datatypes.ByteString[] pattern,
javatools.datatypes.ByteString[] newAtom)
public static boolean unifies(javatools.datatypes.ByteString[] test,
java.util.List<javatools.datatypes.ByteString[]> query)
public static java.util.List<javatools.datatypes.ByteString[]> redundantAtoms(javatools.datatypes.ByteString[] test,
java.util.List<javatools.datatypes.ByteString[]> query)
test - query - public boolean containsUnifiablePatterns()
public java.lang.String toString()
toString in class java.lang.Objectpublic java.util.List<javatools.datatypes.ByteString> getVariables()
public boolean containsRepeatedVariablesInLastPattern()
public boolean isRedundantRecursive()
public boolean isEmpty()
public boolean isClosed()
public boolean isPerfect()
public java.lang.String getHeadKey()
public java.lang.String getHeadRelation()
public javatools.datatypes.ByteString getHeadRelationBS()
public int getLength()
public int getRealLength()
public int getRealLengthWithoutTypes(javatools.datatypes.ByteString typeString)
public int getLengthWithoutTypes(javatools.datatypes.ByteString typeString)
typeString - public int getLengthWithoutTypesAndLinksTo(javatools.datatypes.ByteString typeString,
javatools.datatypes.ByteString linksString)
typeString - public void setParent(Rule parent)
parent - public Rule addAtom(javatools.datatypes.ByteString[] newAtom, int cardinality, javatools.datatypes.ByteString joinedVariable, javatools.datatypes.ByteString danglingVariable)
newAtom - The new atom.cardinality - The support of the new rule.joinedVariable - The position of the common variable w.r.t to the
rule in the new atom, i.e., 0 if the new atoms joins on the subject or 2
if it joins on the object.danglingVariable - The position of the fresh variable in the new
atom.public Rule addAtom(javatools.datatypes.ByteString[] newAtom, double cardinality)
public int alternativeParentHashCode()
public int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic static void printRuleBasicHeaders()
public static void printRuleHeaders()
public java.lang.String getRuleString()
public java.lang.String getFullRuleString()
public java.lang.String getBasicRuleString()
public static java.lang.String toDatalog(javatools.datatypes.ByteString[] atom)
public java.lang.String getDatalogString()
public Rule instantiateConstant(int danglingPosition, javatools.datatypes.ByteString constant, double cardinality)
danglingPosition - constant - cardinality - public Rule instantiateConstant(int triplePos, int danglingPosition, javatools.datatypes.ByteString constant, double cardinality)
triplePos - danglingPosition - constant - cardinality - public java.util.List<Rule> getAncestors()
public java.util.List<Rule> getAllAncestors()
public void setBodyMinusHeadSize(int size)
public long getBodyMinusHeadSize()
public void setPcaBodySize(double size)
public double getPcaBodySize()
public boolean _isBelowMinimumSupport()
public void _setBelowMinimumSupport(boolean belowMinimumSupport)
public boolean _containsQuasiBindings()
public void _setContainsQuasibinding(boolean containsQuasiBindings)
public Rule rewriteQuery(javatools.datatypes.ByteString[] remove, javatools.datatypes.ByteString[] target, javatools.datatypes.ByteString victimVar, javatools.datatypes.ByteString targetVar)
public boolean variableCanBeDeleted(int triplePos,
int varPos)
public void setConfidenceUpperBound(double stdConfUpperBound)
public void setPcaConfidenceUpperBound(double pcaConfUpperBound)
public double getPcaEstimation()
public void setPcaEstimation(double pcaEstimation)
pcaEstimation - the pcaEstimation to setpublic boolean containsLevel2RedundantSubgraphs()
public boolean containsDisallowedDiamond()
public static void bind(java.util.Map<javatools.datatypes.ByteString,javatools.datatypes.ByteString> mappings,
java.util.List<javatools.datatypes.ByteString[]> inputTriples)
mappings - inputTriples - public static void bind(javatools.datatypes.ByteString oldVal,
javatools.datatypes.ByteString newVal,
java.util.List<javatools.datatypes.ByteString[]> query)
oldVal - newVal - query - public boolean hasConfidenceGain()
public java.util.List<javatools.datatypes.ByteString[]> getPCAQuery()
public static Rule combineRules(java.util.List<Rule> rules)
rules - public boolean containsRelation(javatools.datatypes.ByteString relation)
public int containsRelationTimes(javatools.datatypes.ByteString relation)
public static void getParentsOfSize(java.util.List<javatools.datatypes.ByteString[]> antecedent,
javatools.datatypes.ByteString[] head,
int windowSize,
java.util.List<java.util.List<javatools.datatypes.ByteString[]>> output)
antecedent - head - public boolean containsSinglePath()
public java.util.Set<javatools.datatypes.ByteString> getBodyVariables()
public java.util.List<javatools.datatypes.ByteString> getHeadVariables()
public java.util.List<javatools.datatypes.ByteString[]> getCanonicalPath()
public static int[] joinPositions(javatools.datatypes.ByteString[] a1,
javatools.datatypes.ByteString[] a2)
a1 - a2 - public Rule addEdges(javatools.datatypes.ByteString[] newEdge1, javatools.datatypes.ByteString[] newEdge2)
newEdge1 - newEdge2 - public java.util.List<javatools.datatypes.ByteString> getBodyRelations()
public static void main(java.lang.String[] args)