Package org.semanticweb.owlapi.model

Examples of org.semanticweb.owlapi.model.OWLOntology


    @Test
    public void missingDeclaration() throws OWLOntologyCreationException {
        // given
        String input = "<urn:test#fm2.owl> rdf:type owl:Ontology.\n <urn:test#numberOfPads> rdf:type owl:ObjectProperty ;\n rdfs:domain <urn:test#Settlement> .";
        // when
        OWLOntology o = loadOntologyFromString(input);
        // then
        for (OWLLogicalAxiom ax : o.getLogicalAxioms()) {
            assertTrue(ax instanceof OWLAnnotationAssertionAxiom);
        }
    }
View Full Code Here


                + "         xmlns:rdfs=\"http://www.w3.org/2000/01/rdf-schema#\" xmlns:owl=\"http://www.w3.org/2002/07/owl#\"\n"
                + "         xmlns:xsd=\"http://www.w3.org/2001/XMLSchema#\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n\n"
                + "        <rdf:Description rdf:about=\"urn:test#ind\">\n"
                + "            <rdfs:comment rdf:datatype=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#PlainLiteral\">test</rdfs:comment>\n"
                + "        </rdf:Description>\n" + "    </rdf:RDF>";
        OWLOntology o = loadOntologyFromString(input);
        IRI i = IRI("urn:test#ind");
        assertEquals(
                o.getAnnotationAssertionAxioms(i).iterator().next(),
                AnnotationAssertion(RDFSComment(), i,
                        Literal("test", OWL2Datatype.RDF_PLAIN_LITERAL)));
    }
View Full Code Here

        assertNotNull(node.getBuiltInDatatype());
    }

    @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",
View Full Code Here

        assertTrue(out.toString(), out.toString().contains(expected));
    }

    @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));
View Full Code Here

        assertTrue(saveOntology(o).toString().contains(expected));
    }

    @Test
    public void testPlainLiteralSerializationComments2() throws Exception {
        OWLOntology o = m.createOntology();
        OWLLiteral l = m.getOWLDataFactory().getOWLLiteral("test",
                OWL2Datatype.RDF_PLAIN_LITERAL);
        OWLAnnotation a = m.getOWLDataFactory().getOWLAnnotation(
                m.getOWLDataFactory().getRDFSComment(), l);
        m.applyChange(new AddOntologyAnnotation(o, a));
View Full Code Here

    @Test
    public void shouldNotLoadWrong() throws OWLOntologyCreationException {
        OWLOntologyManager m = OWLManager.createOWLOntologyManager();
        m.createOntology(IRI.create("urn:test"));
        StringDocumentSource documentSource = new StringDocumentSource(input);
        OWLOntology o = m.loadOntologyFromOntologyDocument(documentSource);
        assertTrue(o.getOntologyID().toString(), o.isAnonymous());
        assertFalse(o.getOntologyID().getDefaultDocumentIRI().isPresent());
    }
View Full Code Here

     *         exception
     */
    public void shouldLoad() throws Exception {
        // Get hold of an ontology manager
        OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
        OWLOntology pizzaOntology = loadPizza(manager);
        // Remove the ontology so that we can load a local copy.
        manager.removeOntology(pizzaOntology);
        OWLOntology localPizza = loadPizza(manager);
        // We can always obtain the location where an ontology was loaded from;
        // for this test, though, since the ontology was loaded from a string,
        // this does not return a file
        IRI documentIRI = manager.getOntologyDocumentIRI(localPizza);
        // Remove the ontology again so we can reload it later
        manager.removeOntology(pizzaOntology);
        // In cases where a local copy of one of more ontologies is used, an
        // ontology IRI mapper can be used to provide a redirection mechanism.
        // This means that ontologies can be loaded as if they were located on
        // the web. In this example, we simply redirect the loading from
        // http://owl.cs.manchester.ac.uk/co-ode-files/ontologies/pizza.owl to
        // our local copy
        // above.
        // iri and file here are used as examples
        IRI iri = IRI
                .create("http://owl.cs.manchester.ac.uk/co-ode-files/ontologies/pizza.owl");
        File file = folder.newFile();
        manager.getIRIMappers().add(new SimpleIRIMapper(iri, IRI.create(file)));
        // Load the ontology as if we were loading it from the web (from its
        // ontology IRI)
        IRI pizzaOntologyIRI = IRI
                .create("http://owl.cs.manchester.ac.uk/co-ode-files/ontologies/pizza.owl");
        OWLOntology redirectedPizza = manager.loadOntology(pizzaOntologyIRI);
        IRI pizza = manager.getOntologyDocumentIRI(redirectedPizza);
        // Note that when imports are loaded an ontology manager will be
        // searched for mappings
    }
View Full Code Here

     */
    @Test
    public void shouldSaveOntologies() throws Exception {
        // Get hold of an ontology manager
        OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
        OWLOntology pizzaOntology = loadPizza(manager);
        // Now save a local copy of the ontology. (Specify a path appropriate to
        // your setup)
        File file = folder.newFile("owlapiexamples_saving.owl");
        manager.saveOntology(pizzaOntology, IRI.create(file.toURI()));
        // By default ontologies are saved in the format from which they were
View Full Code Here

        // above manner does not "add them to an ontology". They are merely
        // objects that allow us to reference certain objects (classes etc.) for
        // use in class expressions, and axioms (which can be added to an
        // ontology). Lets create an ontology, and add a declaration axiom to
        // the ontology that declares the above class
        OWLOntology ontology = manager
                .createOntology(IRI
                        .create("http://www.semanticweb.org/owlapi/ontologies/ontology"));
        // We can add a declaration axiom to the ontology, that essentially adds
        // the class to the signature of our ontology.
        OWLDeclarationAxiom declarationAxiom = factory
View Full Code Here

public class MissingDeclarationRoundTripTestCase extends TestBase {

    @Test
    public void shouldFindOneAxiom() throws Exception {
        OWLAnnotationProperty p = AnnotationProperty(IRI("http://test.org/MissingDeclaration.owl#p"));
        OWLOntology ontology = createOntology(p);
        assertTrue(ontology.containsAnnotationPropertyInSignature(p.getIRI(),
                EXCLUDED));
        assertEquals(1, ontology.getAxiomCount());
        RDFXMLDocumentFormat format = new RDFXMLDocumentFormat();
        format.setAddMissingTypes(false);
        ontology = loadOntologyStrict(saveOntology(ontology, format));
        assertFalse(ontology.containsAnnotationPropertyInSignature(p.getIRI(),
                EXCLUDED));
        assertEquals(0, ontology.getAxiomCount());
    }
View Full Code Here

TOP

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

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.