@Override public Set<ATermAppl> getSubjects(final KnowledgeBase kb, final ATermAppl obj) { return kb.getInstances(obj, true); }
@Override public Set<ATermAppl> getSubjects(final KnowledgeBase kb, final ATermAppl obj) { return kb.getInstances(obj, true); }
@Override public Set<ATermAppl> getSubjects(final KnowledgeBase kb, final ATermAppl obj) { return kb.getInstances(obj, true); }
@Override public boolean contains(final KnowledgeBase kb, final GraphLoader loader, final Node s, final Node p, final Node o) { return kb.getInstances(loader.node2term(o), true).contains(loader.node2term(s)); } });
@Override public boolean contains(final KnowledgeBase kb, final GraphLoader loader, final Node s, final Node p, final Node o) { return kb.getInstances(loader.node2term(o), true).contains(loader.node2term(s)); } });
@Override public boolean contains(final KnowledgeBase kb, final GraphLoader loader, final Node s, final Node p, final Node o) { return kb.getInstances(loader.node2term(o), true).contains(loader.node2term(s)); } });
@Override public ExtendedIterator<Triple> find(final KnowledgeBase kb, final PelletInfGraph openllet, final Node s, final Node p, final Node o) { return subjectFiller(kb.getInstances(openllet.getLoader().node2term(o)), p, o); } });
@Override public ExtendedIterator<Triple> find(final KnowledgeBase kb, final PelletInfGraph openllet, final Node s, final Node p, final Node o) { return subjectFiller(kb.getInstances(openllet.getLoader().node2term(o)), p, o); } });
@Override public ExtendedIterator<Triple> find(final KnowledgeBase kb, final PelletInfGraph openllet, final Node s, final Node p, final Node o) { return subjectFiller(kb.getInstances(openllet.getLoader().node2term(o)), p, o); } });
@Override public NodeSet<OWLNamedIndividual> getInstances(final OWLClassExpression ce, final boolean direct) throws InconsistentOntologyException, ClassExpressionNotInProfileException, FreshEntitiesException, ReasonerInterruptedException, TimeOutException { refreshCheck(); try { return getIndividualNodeSet(_kb.getInstances(term(ce), direct)); } catch (final PelletRuntimeException e) { throw convert(e); } }
@Override public NodeSet<OWLNamedIndividual> getInstances(final OWLClassExpression ce, final boolean direct) throws InconsistentOntologyException, ClassExpressionNotInProfileException, FreshEntitiesException, ReasonerInterruptedException, TimeOutException { refreshCheck(); try { return getIndividualNodeSet(_kb.getInstances(term(ce), direct)); } catch (final PelletRuntimeException e) { throw convert(e); } }
@Override public NodeSet<OWLNamedIndividual> getInstances(final OWLClassExpression ce, final boolean direct) throws InconsistentOntologyException, ClassExpressionNotInProfileException, FreshEntitiesException, ReasonerInterruptedException, TimeOutException { refreshCheck(); try { return getIndividualNodeSet(_kb.getInstances(term(ce), direct)); } catch (final PelletRuntimeException e) { throw convert(e); } }
_logger.finer(currVar + " rolled to " + rolledUpClass); final Set<ATermAppl> inst = kb.getInstances(rolledUpClass); varBindings.put(currVar, inst);
_logger.finer(currVar + " rolled to " + rolledUpClass); final Set<ATermAppl> inst = kb.getInstances(rolledUpClass); varBindings.put(currVar, inst);
instances = _kb.getInstances(clazz);
@Test public void testNoVarTypeAtom() { classes(_A, _B, _C); dataProperties(_q); individuals(_a, _b); _kb.addType(_a, _A); _kb.addType(_b, _B); final ATermAppl t = TermFactory.literal("t"); final ATermAppl f = TermFactory.literal("f"); final AtomIVariable x = new AtomIVariable("x"); List<RuleAtom> body = Arrays.<RuleAtom> asList(new ClassAtom(_A, x), new ClassAtom(_B, new AtomIConstant(_b))); List<RuleAtom> head = Arrays.<RuleAtom> asList(new DatavaluedPropertyAtom(_q, x, new AtomDConstant(t))); _kb.addRule(new Rule(head, body)); body = Arrays.<RuleAtom> asList(new ClassAtom(_A, x), new ClassAtom(_A, new AtomIConstant(_b))); head = Arrays.<RuleAtom> asList(new DatavaluedPropertyAtom(_q, x, new AtomDConstant(f))); _kb.addRule(new Rule(head, body)); body = Arrays.<RuleAtom> asList(new ClassAtom(_B, x)); head = Arrays.<RuleAtom> asList(new ClassAtom(_C, x)); _kb.addRule(new Rule(head, body)); assertIteratorValues(_kb.getDataPropertyValues(_q, _a).iterator(), t); assertIteratorValues(_kb.getDataPropertyValues(_q, _b).iterator()); assertIteratorValues(_kb.getInstances(_C).iterator(), _b); }
@Test public void testReflexive3() { classes(_C); objectProperties(_r); individuals(_a, _b, _c); _kb.addEquivalentClass(_C, self(_r)); _kb.addPropertyValue(_r, _a, _a); _kb.addType(_b, _C); _kb.addPropertyValue(_r, _c, _a); _kb.addPropertyValue(_r, _c, _b); assertTrue(_kb.hasPropertyValue(_a, _r, _a)); assertTrue(_kb.hasPropertyValue(_b, _r, _b)); assertFalse(_kb.hasPropertyValue(_c, _r, _c)); final Map<ATermAppl, List<ATermAppl>> allRs = _kb.getPropertyValues(_r); assertIteratorValues(allRs.get(_a).iterator(), new ATermAppl[] { _a }); assertIteratorValues(allRs.get(_b).iterator(), new ATermAppl[] { _b }); assertIteratorValues(allRs.get(_c).iterator(), new ATermAppl[] { _a, _b }); assertTrue(_kb.isType(_a, _C)); assertTrue(_kb.isType(_b, _C)); assertFalse(_kb.isType(_c, _C)); assertEquals(_kb.getInstances(_C), SetUtils.create(_a, _b)); }
@Test public void testBindingBuiltins() { classes(_A); dataProperties(_p, _q); individuals(_a, _b, _c, _d); _kb.addPropertyValue(_p, _a, TermFactory.literal(1)); _kb.addPropertyValue(_p, _b, TermFactory.literal(5)); _kb.addPropertyValue(_p, _c, TermFactory.literal(10)); _kb.addPropertyValue(_p, _d, TermFactory.literal(15)); final AtomIVariable x = new AtomIVariable("x"); final AtomDVariable y = new AtomDVariable("y"); final AtomDVariable z = new AtomDVariable("z"); final List<RuleAtom> body = Arrays.<RuleAtom> asList(new DatavaluedPropertyAtom(_p, x, y), new BuiltInAtom(SWRLB + "pow", z, y, new AtomDConstant(TermFactory.literal(2))), new BuiltInAtom(SWRLB + "lessThan", z, new AtomDConstant(TermFactory.literal(100)))); final List<RuleAtom> head = Arrays.<RuleAtom> asList(new ClassAtom(_A, x)); _kb.addRule(new Rule(head, body)); assertIteratorValues(_kb.getInstances(_A).iterator(), _a, _b); }
assertEquals(Collections.singleton(ind[i]), _kb.getInstances(cls[i]));
@Test public void testDisjointPropertiesCache() { // test case for issue #336 to verify AbstractConceptCache.isMergable does // not return incorrect results. final KnowledgeBase kb = new KnowledgeBaseImpl(); final ATermAppl p1 = term("p1"); final ATermAppl p2 = term("p2"); final ATermAppl a = term("a"); final ATermAppl b = term("b"); final ATermAppl c = term("c"); kb.addObjectProperty(p1); kb.addObjectProperty(p2); kb.addDisjointProperty(p1, p2); kb.addIndividual(a); kb.addIndividual(b); kb.addIndividual(c); kb.addPropertyValue(p1, a, c); kb.addPropertyValue(p2, b, a); final ATermAppl notp1a = ATermUtils.makeNot(ATermUtils.makeHasValue(p1, a)); // no caching so consistency checking will be used here assertFalse(kb.isType(a, notp1a)); assertTrue(kb.isType(b, notp1a)); // call getInstances so some caching will happen assertEquals(singleton(b), kb.getInstances(notp1a, false)); // now cached _nodes will be used for mergable check assertFalse(kb.isType(a, notp1a)); assertTrue(kb.isType(b, notp1a)); }