private TriplePattern makeSubOfSomeTriple(Node t1, Node p, Node t2) { return new TriplePattern(t1, p, t2); }
private TriplePattern makeSubOfSomeTriple(Node t1, Node p, Node t2) { return new TriplePattern(t1, p, t2); }
private TriplePattern makeSubclassTriple(Node t1, Node t2) { return new TriplePattern(t1, PRED_SUB, t2); }
private TriplePattern makeSubclassTriple(Node t1, Node t2) { return new TriplePattern(t1, PRED_SUB, t2); }
/** * Search the combination of data and deductions graphs for the given triple pattern. * This may different from the normal find operation in the base of hybrid reasoners * where we are side-stepping the backward deduction step. */ @Override public ExtendedIterator<Triple> findDataMatches(Node subject, Node predicate, Node object) { return dataFind.find(new TriplePattern(subject, predicate, object)); }
/** * Search the combination of data and deductions graphs for the given triple pattern. * This may different from the normal find operation in the base of hybrid reasoners * where we are side-stepping the backward deduction step. */ @Override public ExtendedIterator<Triple> findDataMatches(Node subject, Node predicate, Node object) { return findWithContinuation(new TriplePattern(subject, predicate, object), null, false); }
/** * @see com.hp.hpl.jena.reasoner.rulesys.RuleContext#find(com.hp.hpl.jena.graph.Node, com.hp.hpl.jena.graph.Node, com.hp.hpl.jena.graph.Node) */ @Override public ClosableIterator<Triple> find(Node s, Node p, Node o) { return graph.findDataMatches(new TriplePattern(s, p, o)); // return searchpath.find(new TriplePattern(s, p, o)); }
/** * Returns an iterator over Triples. * This implementation assumes that the underlying findWithContinuation * will have also consulted the raw data. */ @Override public ExtendedIterator<Triple> graphBaseFind(Node subject, Node property, Node object) { return findWithContinuation(new TriplePattern(subject, property, object), null); }
/** * Returns an iterator over Triples. * This implementation assumes that the underlying findWithContinuation * will have also consulted the raw data. */ @Override public ExtendedIterator<Triple> graphBaseFind(Node subject, Node property, Node object) { return findWithContinuation(new TriplePattern(subject, property, object), fdata); }
/** * Returns an iterator over Triples. */ @Override public ExtendedIterator<Triple> graphBaseFind(Node subject, Node property, Node object) { return findWithContinuation(new TriplePattern(subject, property, object), fdata); }
/** * Returns an iterator over Triples. * This implementation assumes that the underlying findWithContinuation * will have also consulted the raw data. */ @Override public ExtendedIterator<Triple> graphBaseFind(Node subject, Node property, Node object) { return findWithContinuation(new TriplePattern(subject, property, object), null); }
/** * Returns an iterator over Triples. * This implementation assumes that the underlying findWithContinuation * will have also consulted the raw data. */ @Override public ExtendedIterator<Triple> graphBaseFind(Node subject, Node property, Node object) { return findWithContinuation(new TriplePattern(subject, property, object), null); }
/** * Helper - returns the (singleton) value for the given property on the given * root node in the data graph. */ public static Node getPropValue(Node root, Node prop, Finder context) { return doGetPropValue(context.find(new TriplePattern(root, prop, null))); }
/** * Create a deep copy of the cache contents. * Works by creating a completely new cache and just adding in the * direct links. */ public TransitiveGraphCache deepCopy() { TransitiveGraphCache copy = new TransitiveGraphCache(directPredicate, closedPredicate); Iterator<Triple> i = find(new TriplePattern(null, directPredicate, null)); while (i.hasNext()) { Triple t = i.next(); copy.addRelation(t.getSubject(), t.getObject()); } return copy; }
public static boolean isSubTypeOf(String aUri, String bUri) { return tgc.contains( new TriplePattern(NodeFactory.createURI(aUri), RDFS.subClassOf.asNode(), NodeFactory.createURI(bUri)) ); } }
public static boolean isSubTypeOf(Resource a, Resource b) { return tgc.contains( new TriplePattern(a.asNode(), RDFS.subClassOf.asNode(), b.asNode()) ); }
/** * Bind the variables in a goal pattern using the binding environment, to * generate a more specialized goal * @param goal the TriplePattern to be instantiated * @return a TriplePattern obtained from the goal by substituting current bindinds */ public TriplePattern partInstantiate(TriplePattern goal) { return new TriplePattern( getGroundVersion(goal.getSubject()), getGroundVersion(goal.getPredicate()), getGroundVersion(goal.getObject()) ); }
/** * Cache all instances of the given predicate which are * present in the given Graph. * @param graph the searchable set of triples to cache * @param predicate the predicate to cache, need not be the registered * predicate due to subProperty declarations * @return returns true if new information has been cached */ public boolean cacheAll(Finder graph, Node predicate) { ExtendedIterator<Triple> it = graph.find(new TriplePattern(null, predicate, null)); boolean foundsome = it.hasNext(); while (it.hasNext()) { addRelation(it.next()); } it.close(); return foundsome; }
/** * Clone a clause, cloning any embedded variables. */ private ClauseEntry cloneClause(ClauseEntry clause, Map<Node_RuleVariable, Node> vmap, BindingEnvironment env) { if (clause instanceof TriplePattern) { TriplePattern tp = (TriplePattern)clause; return new TriplePattern ( cloneNode(tp.getSubject(), vmap, env), cloneNode(tp.getPredicate(), vmap, env), cloneNode(tp.getObject(), vmap, env) ); } else { return cloneFunctor((Functor)clause, vmap, env); } }
@Override public ExtendedIterator<Triple> findWithContinuation(TriplePattern pattern, Finder finder) { prepare(); Node subject = pattern.getSubject(); Node predicate = pattern.getPredicate(); Node object = pattern.getObject(); ExtendedIterator<Triple> i = GraphQueryHandler.findTriple( kb, this, subject, predicate, object ); // always look at asserted triples at the end if( finder != null ) { TriplePattern tp = new TriplePattern( subject, predicate, object ); i = i.andThen( finder.find( tp ) ); } // make sure we don't have duplicates return UniqueExtendedIterator.create( i ); }