/** * Transform a statement pattern to infer triples for a predicate variable. * * @param node the node to transform * @return list of nodes to visit next */ @Override public List<QueryModelNode> apply(StatementPattern node) { List<QueryModelNode> next = newNextList(); StatementPattern left = node.clone(); next.add(left); TupleExpr right = assignPredicates(predicates, node.clone(), next); node.replaceWith(new Union(left, right)); return next; }
/** * Transform a statement pattern according to OWL-2 property chain * axiom. * * @param node the node to transform * @return list of nodes to visit next */ @Override public List<QueryModelNode> apply(StatementPattern node) { List<QueryModelNode> next = newNextList(); Var s = node.getSubjectVar(); Var o = node.getObjectVar(); Var c = node.getContextVar(); TupleExpr left = node.clone(); TupleExpr right = getChain(s, o, c); node.replaceWith(new Union(left, right)); next.add(left); next.add(right); return next; }
public Rule getFreshRule() throws Exception { StatementPattern consequentClone = consequent.clone(); TupleExpr antecedentClone = antecedent.clone();
@Override protected void meetSP(final StatementPattern node) throws Exception { final StatementPattern currentNode = node.clone(); final Var subVar = node.getSubjectVar(); final Var predVar = node.getPredicateVar();
/** * Transform a statement pattern according to OWL-2 subproperty axiom. * * @param node the node to transform * @return list of nodes to visit next */ @Override public List<QueryModelNode> apply(StatementPattern node) { List<QueryModelNode> next = newNextList(); StatementPattern left = node.clone(); // replace the predicate with the subproperty StatementPattern right = new StatementPattern( node.getSubjectVar(), new ConstVar(vf.createURI(op1)), node.getObjectVar(), node.getContextVar()); node.replaceWith( new Union(left, right)); next.add(left); next.add(right); return next; }
/** * Transform a statement pattern according to OWL-2 subclass axiom. * * @param node the node to transform * @return list of nodes to visit next */ @Override public List<QueryModelNode> apply(StatementPattern node) { List<QueryModelNode> next = newNextList(); StatementPattern left = node.clone(); // replace the object with the subclass StatementPattern right = new StatementPattern( node.getSubjectVar(), node.getPredicateVar(), new ConstVar(vf.createURI(ce1)), node.getContextVar()); node.replaceWith( new Union(left, right)); next.add(left); next.add(right); return next; }
@Override protected void meetSP(final StatementPattern node) throws Exception { final StatementPattern sp = node.clone(); final Var predVar = sp.getPredicateVar(); final URI pred = (URI) predVar.getValue(); final String predNamespace = pred.getNamespace(); final Var objVar = sp.getObjectVar(); final Var cntxtVar = sp.getContextVar(); if (objVar != null && !RDF.NAMESPACE.equals(predNamespace) && !SESAME.NAMESPACE.equals(predNamespace) && !RDFS.NAMESPACE.equals(predNamespace) && !EXPANDED.equals(cntxtVar)) { final URI transPropUri = (URI) predVar.getValue(); if (inferenceEngine.isTransitiveProperty(transPropUri)) { node.replaceWith(new TransitivePropertySP(sp.getSubjectVar(), sp.getPredicateVar(), sp.getObjectVar(), sp.getContextVar())); } } } }
@Override protected void meetSP(StatementPattern node) throws Exception { StatementPattern sp = node.clone();
@Override protected void meetSP(final StatementPattern node) throws Exception { final StatementPattern sp = node.clone(); final Var predVar = sp.getPredicateVar();
@Override protected void meetSP(final StatementPattern node) throws Exception { final StatementPattern sp = node.clone(); final Var predVar = sp.getPredicateVar();
p2 = new ConstVar(vf.createURI(op1)); StatementPattern left = node.clone();
if (sufficientValues.size() > 0) { final Var valueVar = new Var("v-" + UUID.randomUUID()); TupleExpr currentNode = node.clone(); for (URI property : sufficientValues.keySet()) { final Var propVar = new Var(property.toString(), property); final TupleExpr typeSP = new DoNotExpandSP(subjVar, rdfTypeVar, typeVar); final FixedStatementPattern typeToValue = new FixedStatementPattern(typeVar, hasValueVar, objVar); final TupleExpr directValueSP = node.clone(); for (Resource type : impliedValues.keySet()) {
@Override protected void meetSP(final StatementPattern node) throws Exception { final StatementPattern sp = node.clone(); final Var predVar = sp.getPredicateVar(); final Var objVar = sp.getObjectVar();
@Override protected void meetSP(StatementPattern node) throws Exception { StatementPattern sp = node.clone(); final Var predVar = sp.getPredicateVar();
node.replaceWith(new InferUnion(node.clone(), svfInferenceQuery));
node.replaceWith(new InferUnion(node.clone(), avfInferenceQuery));
/** * Check whether any solution for the {@link StatementPattern} could be derived from * reflexive property inference, and if so, replace the pattern with a union of itself and the * reflexive solution. */ @Override protected void meetSP(StatementPattern node) throws Exception { // Only applies when the predicate is defined and reflexive final Var predVar = node.getPredicateVar(); if (predVar.getValue() != null && inferenceEngine.isReflexiveProperty((URI) predVar.getValue())) { final StatementPattern originalSP = node.clone(); // The reflexive solution is a ZeroLengthPath between subject and // object: they can be matched to one another, whether constants or // variables. final Var subjVar = node.getSubjectVar(); final Var objVar = node.getObjectVar(); final ZeroLengthPath reflexiveSolution = new ZeroLengthPath(subjVar, objVar); node.replaceWith(new InferUnion(originalSP, reflexiveSolution)); } } }
final URI inferredType = (URI) objVar.getValue(); TupleExpr currentNode = node.clone();
final StatementPattern clone = node.clone(); if (RDF.TYPE.equals(pred) && obj.isConstant()) {