public void classify() { prepare(); _kb.classify(); }
public void classify() { prepare(); _kb.classify(); }
public void classify() { prepare(); _kb.classify(); }
public ClassTree(final String ontology) { // create a reasoner _model = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC); // create a _model for the ontology System.out.print("Reading..."); _model.read(ontology); System.out.println("done"); // load the _model to the reasoner System.out.print("Preparing..."); _model.prepare(); System.out.println("done"); // compute the classification tree System.out.print("Classifying..."); ((PelletInfGraph) _model.getGraph()).getKB().classify(); System.out.println("done"); }
public ClassTree(final String ontology) { // create a reasoner _model = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC); // create a _model for the ontology System.out.print("Reading..."); _model.read(ontology); System.out.println("done"); // load the _model to the reasoner System.out.print("Preparing..."); _model.prepare(); System.out.println("done"); // compute the classification tree System.out.print("Classifying..."); ((PelletInfGraph) _model.getGraph()).getKB().classify(); System.out.println("done"); }
/** * Performs classification using the non-incremental (classic) classifier */ private void runClassicClassify() { final KnowledgeBase kb = getKB(); startTask("consistency check"); final boolean isConsistent = kb.isConsistent(); finishTask("consistency check"); if (!isConsistent) throw new OpenlletCmdException("Ontology is inconsistent, run \"openllet explain\" to get the reason"); startTask("classification"); kb.classify(); finishTask("classification"); final TaxonomyPrinter<ATermAppl> printer = new ClassTreePrinter(); printer.print(kb.getTaxonomy()); }
@Test public void testBottomSub() { // See also: http://cvsdude.com/trac/clark-parsia/pellet-devel/ticket/7 final KnowledgeBase kb = new KnowledgeBaseImpl(); final ATermAppl c = term("c"); kb.addClass(c); kb.addSubClass(ATermUtils.BOTTOM, c); kb.classify(); assertTrue(kb.isSubClassOf(ATermUtils.BOTTOM, c)); }
@Test public void testDisjointSelf() { final KnowledgeBase kb = new KnowledgeBaseImpl(); final ATermAppl A = term("A"); final ATermAppl p = term("p"); kb.addClass(A); kb.addObjectProperty(p); kb.addDisjointClasses(Arrays.asList(A, self(p))); kb.classify(); assertTrue(kb.isSatisfiable(A)); }
private static void runComparisonTest(final OWLOntology ontology, final ModuleExtractor modExtractor, final ReasonerComparisonMethod comparisonMethod) { final OpenlletReasoner unified = OpenlletReasonerFactory.getInstance().createNonBufferingReasoner(ontology); final IncrementalClassifier modular = PelletIncremantalReasonerFactory.getInstance().createReasoner(ontology, modExtractor); OpenlletOptions.USE_CLASSIFICATION_MONITOR = OpenlletOptions.MonitorType.CONSOLE; modular.classify(); unified.getKB().classify(); comparisonMethod.compare(unified, modular); modular.dispose(); }
/** * not A subClassOf A implies A is TOP */ @Test public void testTopClass4() { classes(_A, _B, _C); _kb.addSubClass(not(_A), _A); _kb.addSubClass(_B, _A); assertTrue(_kb.isConsistent()); _kb.classify(); assertTrue(_kb.isEquivalentClass(_A, TOP)); }
@Ignore @Test public void testSetTheory() // This test doesn't work, the url isn't available. { final String ns = "http://www.integratedmodelling.org/ks/tarassandbox/set-theory.owl#"; final OWLOntology ont = loadOntology(OWLManager.createOWLOntologyManager(), _base + "set-theory.owl"); final OpenlletReasoner reasoner = OpenlletReasonerFactory.getInstance().createReasoner(ont); reasoner.getKB().classify(); assertStreamAsSetEquals(Stream.of(OWL.Class(ns + "SetOfXSets"), OWL.Class(ns + "XSet"), OWL.Class(ns + "XThing")), reasoner.getSubClasses(OWL.Class(ns + "XSetTheoryClass"), true).entities()); }
/** * not A subClassOf B does not imply disjointness between concepts A and B. */ @Test public void testNonDisjointness() { classes(_A, _B, _C); _kb.addSubClass(not(_A), _B); _kb.addSubClass(_C, and(_A, _B)); assertTrue(_kb.isConsistent()); _kb.classify(); assertTrue(_kb.isSatisfiable(_C)); }
@Test public void cdClassificationWithInverses() { classes(_C, _D, _E); objectProperties(_p); _kb.addSubClass(_C, some(_p, _D)); _kb.addSubClass(_D, all(inv(_p), _E)); assertTrue(_kb.isConsistent()); assertTrue(_kb.isSubClassOf(_C, _E)); _kb.classify(); assertTrue(_kb.isSubClassOf(_C, _E)); }
@Test public void testDifferentFrom2() { final KnowledgeBase kb = new KnowledgeBaseImpl(); kb.addClass(term("C")); kb.addClass(term("D")); kb.addDisjointClass(term("C"), term("D")); kb.addIndividual(term("a")); kb.addType(term("a"), term("C")); kb.addIndividual(term("b")); kb.addType(term("b"), term("D")); kb.classify(); assertTrue(kb.getDifferents(term("a")).contains(term("b"))); assertTrue(kb.getDifferents(term("b")).contains(term("a"))); }
@Test public void testRoleAbsorptionWithPropertyChain() { classes(_A, _B, _C, _D); objectProperties(_p, _q, _r); _kb.addSubProperty(list(_p, _q), _r); _kb.addSubClass(_C, _B); _kb.addEquivalentClass(_C, some(_r, _D)); _kb.addSubClass(_A, some(_p, some(_q, _D))); assertTrue(_kb.isSubClassOf(_A, _C)); _kb.classify(); assertTrue(_kb.isSubClassOf(_A, _C)); }
private static void runComparisonUpdateTest(final OWLOntology ontology, final ModuleExtractor modExtractor, // final Collection<OWLAxiom> additions, final Collection<OWLAxiom> deletions, final ReasonerComparisonMethod comparisonMethod) { final OpenlletReasoner unified = OpenlletReasonerFactory.getInstance().createNonBufferingReasoner(ontology); final IncrementalClassifier modular = PelletIncremantalReasonerFactory.getInstance().createReasoner(ontology, modExtractor); OpenlletOptions.USE_CLASSIFICATION_MONITOR = OpenlletOptions.MonitorType.CONSOLE; modular.classify(); comparisonMethod.compare(unified, modular); ontology.add(additions); ontology.remove(deletions); modular.classify(); unified.flush(); unified.getKB().classify(); modular._timers.print(); comparisonMethod.compare(unified, modular); modular.dispose(); }
@Test public void cdClassificationWithCyclicInverses() { classes(_C, _D, _E); objectProperties(_p, _q); _kb.addSubClass(_E, some(_p, _C)); _kb.addSubClass(_C, all(inv(_p), _D)); _kb.addSubClass(_D, some(_q, _E)); assertTrue(_kb.isConsistent()); assertTrue(_kb.isSubClassOf(_E, _D)); _kb.classify(); assertTrue(_kb.isSubClassOf(_E, _D)); }
@Test public void testInternalization() { final KnowledgeBase kb = new KnowledgeBaseImpl(); final ATermAppl A = term("A"); final ATermAppl B = term("B"); final ATermAppl C = term("C"); kb.addClass(A); kb.addClass(B); kb.addClass(C); kb.addSubClass(TOP, and(or(B, not(A)), or(C, not(B)))); assertSubClass(kb, A, B); assertSubClass(kb, B, C); kb.classify(); }
@Test public void cdClassificationWithPropChain() { classes(_C, _D, _E); objectProperties(_p, _q, _r); _kb.addSubProperty(list(_p, _q), _r); _kb.addSubClass(_C, some(_p, some(_q, _D))); _kb.addSubClass(_D, all(inv(_r), _E)); assertTrue(_kb.isConsistent()); assertTrue(_kb.isSubClassOf(_C, _E)); _kb.classify(); _kb.printClassTree(); assertTrue(_kb.isSubClassOf(_C, _E)); } }
@Test public void test375() { // test case for issue #375. classes(_A, _B, _C); dataProperties(_p); final ATermAppl dt = restrict(Datatypes.INTEGER, minExclusive(literal(1))); _kb.addRange(_p, XSDInteger.getInstance().getName()); _kb.addSubClass(_A, _C); _kb.addEquivalentClass(_A, some(_p, dt)); _kb.addSubClass(_B, _C); _kb.addEquivalentClass(_B, hasValue(_p, literal(2))); assertTrue(_kb.isConsistent()); assertSubClass(_kb, _B, _A); _kb.classify(); _kb.printClassTree(); assertSubClass(_kb, _B, _A); }