private static OWLEntity createEntity(final String type, final String entityIRI) { if (CLASS_KEYWORD.equals(type)) return OWL.Class(entityIRI); else if (DATA_TYPE_KEYWORD.equals(type)) return OWL.Datatype(entityIRI); else if (INDIVIDUAL_KEYWORD.equals(type)) return OWL.Individual(entityIRI); else if (DATA_PROPERTY_KEYWORD.equals(type)) return OWL.DataProperty(entityIRI); else if (OBJECT_PROPERTY_KEYWORD.equals(type)) return OWL.ObjectProperty(entityIRI); throw new IllegalArgumentException("Unrecognized type of OWLEntity in module " + type); }
private static OWLEntity createEntity(final String type, final String entityIRI) { if (CLASS_KEYWORD.equals(type)) return OWL.Class(entityIRI); else if (DATA_TYPE_KEYWORD.equals(type)) return OWL.Datatype(entityIRI); else if (INDIVIDUAL_KEYWORD.equals(type)) return OWL.Individual(entityIRI); else if (DATA_PROPERTY_KEYWORD.equals(type)) return OWL.DataProperty(entityIRI); else if (OBJECT_PROPERTY_KEYWORD.equals(type)) return OWL.ObjectProperty(entityIRI); throw new IllegalArgumentException("Unrecognized type of OWLEntity in module " + type); }
final OWLDataProperty foafName = OWL.DataProperty("http://xmlns.com/foaf/0.1/name");
final OWLDataProperty foafName = OWL.DataProperty("http://xmlns.com/foaf/0.1/name");
else if (ontology.containsDataPropertyInSignature(iri, Imports.EXCLUDED)) entity = OWL.DataProperty(iri); else if (ontology.containsIndividualInSignature(iri, Imports.EXCLUDED))
else if (ontology.containsDataPropertyInSignature(iri, Imports.EXCLUDED)) entity = OWL.DataProperty(iri); else if (ontology.containsIndividualInSignature(iri, Imports.EXCLUDED))
else if (ontology.containsDataPropertyInSignature(iri, Imports.EXCLUDED)) entity = OWL.DataProperty(iri); else if (ontology.containsIndividualInSignature(iri, Imports.EXCLUDED))
@Test public void koalaHardWorkingDomain() throws Exception { final String ns = "http://protege.stanford.edu/plugins/owl/owl-library/koala.owl#"; final OWLOntology ontology = _manager.loadOntologyFromOntologyDocument(ClassLoader.getSystemResourceAsStream("test/data/modularity/koala.owl")); final OWLClass animal = OWL.Class(ns + "Animal"); final OWLClass person = OWL.Class(ns + "Person"); final OWLDataProperty hardWorking = OWL.DataProperty(ns + "isHardWorking"); setupGenerators(ontology.axioms()); testExplanations(OWL.domain(hardWorking, animal), 0, new OWLAxiom[] { OWL.subClassOf(person, animal), OWL.domain(hardWorking, person) }); }
@Test public void ruleBuiltinTest3() throws Exception { final SWRLVariable y = SWRL.variable(ontologyURI + "year"); final SWRLVariable m = SWRL.variable(ontologyURI + "month"); final SWRLVariable d = SWRL.variable(ontologyURI + "day"); final OWLDataProperty year = OWL.DataProperty(ontologyURI + "year"); final OWLDataProperty month = OWL.DataProperty(ontologyURI + "month"); final OWLDataProperty day = OWL.DataProperty(ontologyURI + "day"); final OWLAxiom[] axioms = { // OWL.propertyAssertion(_a, dp, // OWL.constant("2009-01-02", XSD.DATE)), // SWRL.rule(// SWRL.antecedent(SWRL.propertyAtom(dp, _x, _dx), // SWRL.builtIn(SWRLBuiltInsVocabulary.DATE, _dx, y, m, d)), // SWRL.consequent(SWRL.propertyAtom(year, _x, y), // SWRL.propertyAtom(month, _x, m), // SWRL.propertyAtom(day, _x, d)// )// ) // }; setupGenerators(Stream.of(axioms)); testExplanations(OWL.propertyAssertion(_a, year, OWL.constant(2009)), 1, new OWLAxiom[] { axioms[0], axioms[1] }); }
@Test public void testAxiomConverterRules4() { final KnowledgeBase kb = new KnowledgeBaseImpl(); final AxiomConverter converter = new AxiomConverter(kb, OWL._manager.getOWLDataFactory()); final ATermAppl r = ATermUtils.makeTermAppl("r"); final ATermAppl s = ATermUtils.makeTermAppl("s"); final ATermAppl x = ATermUtils.makeVar("x"); final ATermAppl y = ATermUtils.makeVar("y"); kb.addDatatypeProperty(r); kb.addDatatypeProperty(s); final ATermAppl[] head = new ATermAppl[] { ATermUtils.makePropAtom(r, x, y) }; final ATermAppl[] body = new ATermAppl[] { ATermUtils.makePropAtom(s, x, y) }; final ATermAppl rule = ATermUtils.makeRule(head, body); final OWLAxiom actual = converter.convert(rule); final Set<SWRLAtom> antecedent = new HashSet<>(); final Set<SWRLAtom> consequent = new HashSet<>(); antecedent.add(propertyAtom(DataProperty("s"), variable("x"), variable("y"))); consequent.add(propertyAtom(DataProperty("r"), variable("x"), variable("y"))); final OWLAxiom expected = rule(antecedent, consequent); assertEquals(expected, actual); }
final OpenlletReasoner reasoner = buffering ? OpenlletReasonerFactory.getInstance().createReasoner(ont) : OpenlletReasonerFactory.getInstance().createNonBufferingReasoner(ont); final OWLDataProperty pInt = DataProperty(ns + "pInt"); final OWLDataProperty pDouble = DataProperty(ns + "pDouble"); final OWLDataProperty pBoolean = DataProperty(ns + "pBoolean");
@Before public void createEntities() { _A = OWL.Class(ontologyURI + "A"); _B = OWL.Class(ontologyURI + "B"); _C = OWL.Class(ontologyURI + "C"); _D = OWL.Class(ontologyURI + "D"); _E = OWL.Class(ontologyURI + "E"); _F = OWL.Class(ontologyURI + "F"); _p = OWL.ObjectProperty(ontologyURI + "p"); _q = OWL.ObjectProperty(ontologyURI + "q"); _r = OWL.ObjectProperty(ontologyURI + "r"); dp = OWL.DataProperty(ontologyURI + "dp"); dq = OWL.DataProperty(ontologyURI + "dq"); dr = OWL.DataProperty(ontologyURI + "dr"); _a = OWL.Individual(ontologyURI + "a"); _b = OWL.Individual(ontologyURI + "b"); _c = OWL.Individual(ontologyURI + "c"); _d = OWL.Individual(ontologyURI + "d"); _dt = OWL.Datatype(ontologyURI + "dt"); _anon1 = OWL.AnonymousIndividual("anon1"); _x = SWRL.variable(ontologyURI + "x"); _y = SWRL.variable(ontologyURI + "y"); _dx = SWRL.variable(ontologyURI + "dx"); }
@Test public void testAddAndRemove() throws OWLOntologyCreationException { try (final OWLManagerGroup group = new OWLManagerGroup()) { final OWLOntologyID ontId = OWLHelper.getVersion(IRI.create(NS + "owlapi.add.remove"), 1.0); final OWLHelper owl = new OWLGenericTools(group, ontId, true); owl.addAxiom(OWL.declaration(OWL.DataProperty(NS + "propA"))); owl.addAxiom(OWL.declaration(OWL.Class(NS + "clsA"))); owl.addAxiom(OWL.equivalentClasses(OWL.Class(NS + "clsA"), // OWL.value(OWL.DataProperty(NS + "propA"), OWL.constant(12))// )); assertTrue(owl.getReasoner().instances(OWL.Class(NS + "clsA")).count() == 0); final OWLNamedIndividual x1 = OWL.Individual(NS + "I1"); owl.addAxiom(OWL.classAssertion(x1, OWL.Class(NS + "clsA"))); assertTrue(owl.getReasoner().instances(OWL.Class(NS + "clsA")).count() == 1); owl.removeAxiom(OWL.classAssertion(x1, OWL.Class(NS + "clsA"))); assertTrue(owl.getReasoner().instances(OWL.Class(NS + "clsA")).count() == 0); } // The test is just about not crash. }
@Test public void testAddAndRemove() throws OWLOntologyCreationException { try (final OWLManagerGroup group = new OWLManagerGroup()) { final OWLOntologyID ontId = OWLHelper.getVersion(IRI.create(NS + "owlapi.add.remove"), 1.0); final OWLHelper owl = new OWLGenericTools(group, ontId, true); owl.addAxiom(OWL.declaration(OWL.DataProperty(NS + "propA"))); owl.addAxiom(OWL.declaration(OWL.Class(NS + "clsA"))); owl.addAxiom(OWL.equivalentClasses(OWL.Class(NS + "clsA"), // OWL.value(OWL.DataProperty(NS + "propA"), OWL.constant(12))// )); assertTrue(owl.getReasoner().instances(OWL.Class(NS + "clsA")).count() == 0); final OWLNamedIndividual x1 = OWL.Individual(NS + "I1"); owl.addAxiom(OWL.classAssertion(x1, OWL.Class(NS + "clsA"))); assertTrue(owl.getReasoner().instances(OWL.Class(NS + "clsA")).count() == 1); owl.removeAxiom(OWL.classAssertion(x1, OWL.Class(NS + "clsA"))); assertTrue(owl.getReasoner().instances(OWL.Class(NS + "clsA")).count() == 0); } // The test is just about not crash. }
final OWLHelper owl = new OWLGenericTools(group, ontId, true); final OWLDataProperty property = OWL.DataProperty(NS + "property"); final OWLNamedIndividual individual = OWL.Individual(NS + "individual"); final OWLClass clazz = OWL.Class(NS + "clazz");
final OWLHelper owl = new OWLGenericTools(group, ontId, true); final OWLDataProperty property = OWL.DataProperty(NS + "property"); final OWLNamedIndividual individual = OWL.Individual(NS + "individual"); final OWLClass clazz = OWL.Class(NS + "clazz");
final OWLHelper owl = new OWLGenericTools(group, ontId, true); final OWLDataProperty dpA = OWL.DataProperty(NS + "dpA"); final OWLDataProperty dpB = OWL.DataProperty(NS + "dpB"); final OWLNamedIndividual a = OWL.Individual(NS + "A"); final OWLNamedIndividual b = OWL.Individual(NS + "B");
final OWLHelper owl = new OWLGenericTools(group, ontId, true); final OWLDataProperty dpA = OWL.DataProperty(NS + "dpA"); final OWLDataProperty dpB = OWL.DataProperty(NS + "dpB"); final OWLNamedIndividual a = OWL.Individual(NS + "A"); final OWLNamedIndividual b = OWL.Individual(NS + "B");
final OWLHelper owl = new OWLGenericTools(group, ontId, true); final OWLDataProperty dpA = OWL.DataProperty(NS + "dpA"); final OWLDataProperty dpB = OWL.DataProperty(NS + "dpB"); final OWLNamedIndividual a = OWL.Individual(NS + "A"); final OWLNamedIndividual b = OWL.Individual(NS + "B");
final OWLHelper owl = new OWLGenericTools(group, ontId, true); final OWLDataProperty dpA = OWL.DataProperty(NS + "dpA"); final OWLDataProperty dpB = OWL.DataProperty(NS + "dpB"); final OWLNamedIndividual a = OWL.Individual(NS + "A"); final OWLNamedIndividual b = OWL.Individual(NS + "B");