Package org.semanticweb.owlapi.model

Examples of org.semanticweb.owlapi.model.OWLIndividual


        @Override
        public OWLObjectHasValue translate(IRI mainNode) {
            IRI value = getConsumer().getResourceObject(mainNode,
                    OWL_HAS_VALUE, true);
            assert value != null;
            OWLIndividual individual = getConsumer().translateIndividual(value);
            IRI propertyIRI = getConsumer().getResourceObject(mainNode,
                    OWL_ON_PROPERTY, true);
            assert propertyIRI != null;
            OWLObjectPropertyExpression property = getConsumer()
                    .translateObjectPropertyExpression(propertyIRI);
View Full Code Here


            throws OWLOntologyCreationException {
        String input = "<http://taxonomy.wolterskluwer.de/practicearea/10112>\n a <http://schema.wolterskluwer.de/TaxonomyTerm> , <http://www.w3.org/2004/02/skos/core#Concept> ;\n"
                + "      <http://www.w3.org/2004/02/skos/core#broader>\n [] ;\n"
                + "      <http://www.w3.org/2004/02/skos/core#broader>\n [] .";
        OWLOntology ontology = loadOntologyFromString(input);
        OWLIndividual i = NamedIndividual(IRI("http://taxonomy.wolterskluwer.de/practicearea/10112"));
        OWLAnnotationProperty ap = AnnotationProperty(IRI("http://www.w3.org/2004/02/skos/core#broader"));
        OWLClass c = Class(IRI("http://www.w3.org/2004/02/skos/core#Concept"));
        OWLClass term = Class(IRI("http://schema.wolterskluwer.de/TaxonomyTerm"));
        assertTrue(ontology.containsAxiom(ClassAssertion(c, i)));
        assertTrue(ontology.containsAxiom(ClassAssertion(term, i)));
View Full Code Here

        OWLDataFactory dataFactory = man.getOWLDataFactory();
        // In this case, we would like to state that matthew has a father who is
        // peter. We need a subject and object - matthew is the subject and
        // peter is the object. We use the data factory to obtain references to
        // these individuals
        OWLIndividual matthew = dataFactory.getOWLNamedIndividual(IRI
                .create(base + "#matthew"));
        OWLIndividual peter = dataFactory.getOWLNamedIndividual(IRI.create(base
                + "#peter"));
        // We want to link the subject and object with the hasFather property,
        // so use the data factory to obtain a reference to this object
        // property.
        OWLObjectProperty hasFather = dataFactory.getOWLObjectProperty(IRI
View Full Code Here

        // an ontology, append a # and then a local name. For example we can
        // create the individual 'John', using the ontology URI and appending
        // #John. Note however, that there is no reuqirement that a URI of a
        // class, property or individual that is used in an ontology have a
        // correspondance with the URI of the ontology.
        OWLIndividual john = factory.getOWLNamedIndividual(IRI
                .create(ontologyIRI + "#John"));
        OWLIndividual mary = factory.getOWLNamedIndividual(IRI
                .create(ontologyIRI + "#Mary"));
        OWLIndividual susan = factory.getOWLNamedIndividual(IRI
                .create(ontologyIRI + "#Susan"));
        OWLIndividual bill = factory.getOWLNamedIndividual(IRI
                .create(ontologyIRI + "#Bill"));
        // The ontologies that we created aren't contained in any ontology at
        // the moment. Individuals (or classes or properties) can't directly be
        // added to an ontology, they have to be used in axioms, and then the
        // axioms are added to an ontology. We now want to add some facts to the
        // ontology. These facts are otherwise known as property assertions. In
        // our case, we want to say that John has a wife Mary. To do this we
        // need to have a reference to the hasWife object property (object
        // properties link an individual to an individual, and data properties
        // link and individual to a constant - here, we need an object property
        // because John and Mary are individuals).
        OWLObjectProperty hasWife = factory.getOWLObjectProperty(IRI
                .create(ontologyIRI + "#hasWife"));
        // Now we need to create the assertion that John hasWife Mary. To do
        // this we need an axiom, in this case an object property assertion
        // axiom. This can be thought of as a "triple" that has a subject, john,
        // a predicate, hasWife and an object Mary
        OWLObjectPropertyAssertionAxiom axiom1 = factory
                .getOWLObjectPropertyAssertionAxiom(hasWife, john, mary);
        // We now need to add this assertion to our ontology. To do this, we
        // apply an ontology change to the ontology via the OWLOntologyManager.
        // First we create the change object that will tell the manager that we
        // want to add the axiom to the ontology
        AddAxiom addAxiom1 = new AddAxiom(ont, axiom1);
        // Now we apply the change using the manager.
        manager.applyChange(addAxiom1);
        // Now we want to add the other facts/assertions to the ontology John
        // hasSon Bill Get a refernece to the hasSon property
        OWLObjectProperty hasSon = factory.getOWLObjectProperty(IRI
                .create(ontologyIRI + "#hasSon"));
        // Create the assertion, John hasSon Bill
        OWLAxiom axiom2 = factory.getOWLObjectPropertyAssertionAxiom(hasSon,
                john, bill);
        // Apply the change
        manager.applyChange(new AddAxiom(ont, axiom2));
        // John hasDaughter Susan
        OWLObjectProperty hasDaughter = factory.getOWLObjectProperty(IRI
                .create(ontologyIRI + "#hasDaughter"));
        OWLAxiom axiom3 = factory.getOWLObjectPropertyAssertionAxiom(
                hasDaughter, john, susan);
        manager.applyChange(new AddAxiom(ont, axiom3));
        // John hasAge 33 In this case, hasAge is a data property, which we need
        // a reference to
        OWLDataProperty hasAge = factory.getOWLDataProperty(IRI
                .create(ontologyIRI + "#hasAge"));
        // We create a data property assertion instead of an object property
        // assertion
        OWLAxiom axiom4 = factory.getOWLDataPropertyAssertionAxiom(hasAge,
                john, 33);
        manager.applyChange(new AddAxiom(ont, axiom4));
        // In the above code, 33 is an integer, so we can just pass 33 into the
        // data factory method. Behind the scenes the OWL API will create a
        // typed constant that it will use as the value of the data property
        // assertion. We could have manually created the constant as follows:
        OWLDatatype intDatatype = factory.getIntegerOWLDatatype();
        OWLLiteral thirtyThree = factory.getOWLLiteral("33", intDatatype);
        // We would then create the axiom as follows:
        factory.getOWLDataPropertyAssertionAxiom(hasAge, john, thirtyThree);
        // However, the convenice method is much shorter! We can now create the
        // other facts/assertion for Mary. The OWL API uses a change object
        // model, which means we can stack up changes (or sets of axioms) and
        // apply the changes (or add the axioms) in one go. We will do this for
        // Mary
        Set<OWLAxiom> axioms = new HashSet<OWLAxiom>();
        axioms.add(factory.getOWLObjectPropertyAssertionAxiom(hasSon, mary,
                bill));
        axioms.add(factory.getOWLObjectPropertyAssertionAxiom(hasDaughter,
                mary, susan));
        axioms.add(factory.getOWLDataPropertyAssertionAxiom(hasAge, mary, 31));
        // Add facts/assertions for Bill and Susan
        axioms.add(factory.getOWLDataPropertyAssertionAxiom(hasAge, bill, 13));
        axioms.add(factory.getOWLDataPropertyAssertionAxiom(hasAge, mary, 8));
        // Now add all the axioms in one go - there is a convenience method on
        // OWLOntologyManager that will automatically generate the AddAxiom
        // change objects for us. We need to specify the ontology that the
        // axioms should be added to and the axioms to add.
        manager.addAxioms(ont, axioms);
        // Now specify the genders of John, Mary, Bill and Susan. To do this we
        // need the male and female individuals and the hasGender object
        // property.
        OWLIndividual male = factory.getOWLNamedIndividual(IRI
                .create(ontologyIRI + "#male"));
        OWLIndividual female = factory.getOWLNamedIndividual(IRI
                .create(ontologyIRI + "#female"));
        OWLObjectProperty hasGender = factory.getOWLObjectProperty(IRI
                .create(ontologyIRI + "#hasGender"));
        Set<OWLAxiom> genders = new HashSet<OWLAxiom>();
        genders.add(factory.getOWLObjectPropertyAssertionAxiom(hasGender, john,
View Full Code Here

    @Test
    public void testPlainLiteralSerialization() throws Exception {
        OWLOntology o = m.createOntology();
        OWLDataProperty p = m.getOWLDataFactory().getOWLDataProperty(
                IRI("urn:test#p"));
        OWLIndividual i = m.getOWLDataFactory().getOWLNamedIndividual(
                IRI("urn:test#ind"));
        OWLLiteral l = m.getOWLDataFactory().getOWLLiteral("test",
                OWL2Datatype.RDF_PLAIN_LITERAL);
        m.addAxiom(o,
                m.getOWLDataFactory().getOWLDataPropertyAssertionAxiom(p, i, l));
View Full Code Here

    }

    @Test
    public void testPlainLiteralSerializationComments() throws Exception {
        OWLOntology o = m.createOntology();
        OWLIndividual i = df.getOWLNamedIndividual(IRI("urn:test#ind"));
        OWLLiteral l = m.getOWLDataFactory().getOWLLiteral("test",
                OWL2Datatype.RDF_PLAIN_LITERAL);
        m.addAxiom(o, df.getOWLAnnotationAssertionAxiom(df.getRDFSComment(), i
                .asOWLNamedIndividual().getIRI(), l));
        String expected = "<rdfs:comment>test</rdfs:comment>";
        assertTrue(saveOntology(o).toString().contains(expected));
    }
View Full Code Here

    @Nonnull
    @Override
    protected Set<? extends OWLAxiom> createAxioms() {
        Set<OWLAxiom> axioms = new HashSet<>();
        OWLIndividual ind = AnonymousIndividual("a");
        OWLClass cls = Class(iri("A"));
        axioms.add(ClassAssertion(cls, ind));
        axioms.add(Declaration(cls));
        return axioms;
    }
View Full Code Here

        AbstractAxiomsRoundTrippingTestCase {

    @Nonnull
    @Override
    protected Set<? extends OWLAxiom> createAxioms() {
        OWLIndividual subject = AnonymousIndividual();
        OWLIndividual object = AnonymousIndividual();
        OWLObjectProperty prop = ObjectProperty(iri("prop"));
        Set<OWLAxiom> axioms = new HashSet<>();
        axioms.add(ObjectPropertyAssertion(prop, subject, object));
        axioms.add(Declaration(prop));
        return axioms;
View Full Code Here

public class ClassAssertionAxiomsTestCase extends AbstractRendererAndParser {

    @Nonnull
    @Override
    protected Set<OWLAxiom> getAxioms() {
        OWLIndividual ind = createIndividual();
        OWLClass cls = createClass();
        OWLAxiom ax = df.getOWLClassAssertionAxiom(cls, ind);
        return singleton(ax);
    }
View Full Code Here

        AbstractRendererAndParser {

    @Nonnull
    @Override
    protected Set<OWLAxiom> getAxioms() {
        OWLIndividual subj = createIndividual();
        OWLDataProperty prop = createDataProperty();
        OWLLiteral obj = df.getOWLLiteral("TestConstant");
        OWLAxiom ax = df.getOWLNegativeDataPropertyAssertionAxiom(prop, subj,
                obj);
        return singleton(ax);
View Full Code Here

TOP

Related Classes of org.semanticweb.owlapi.model.OWLIndividual

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.