Package org.semanticweb.owlapi.model

Examples of org.semanticweb.owlapi.model.OWLOntologyIRIMapper


        // specific IRI. Create a mapper that maps the Protege ontology IRI to
        // the document IRI that points to a copy in the TONES ontology
        // repository.
        IRI protegeOntologyDocumentIRI = getTONESRepositoryDocumentIRI(
                protegeOntologyIri, tonesRepositoryIri);
        OWLOntologyIRIMapper iriMapper = new SimpleIRIMapper(
                protegeOntologyIri, protegeOntologyDocumentIRI);
        // Create a new manager that we will use to load the MGED ontology
        OWLOntologyManager manager2 = OWLManager.createOWLOntologyManager();
        // Register our mapper with the manager
        manager2.getIRIMappers().add(iriMapper);
        // Now load our MGED ontology
        OWLOntology ontology2 = loadPizza(manager2);
        // Print out the details
        printOntologyAndImports(manager2, ontology2);
        // Notice that the document IRI of the protege ontology is different to
        // the document IRI of the ontology when it was loaded the first time.
        // This is due to the mapper redirecting the ontology loader. For
        // example, AutoIRIMapper: An AutoIRIMapper finds ontologies in a local
        // folder and maps their IRIs to their locations in this folder We
        // specify a directory/folder where the ontologies are located. In this
        // case we've just specified the tmp directory.
        @Nonnull
        File file = folder.newFolder();
        // We can also specify a flag to indicate whether the directory should
        // be searched recursively.
        OWLOntologyIRIMapper autoIRIMapper = new AutoIRIMapper(file, false);
        // We can now use this mapper in the usual way, i.e.
        manager2.getIRIMappers().add(autoIRIMapper);
        // Of course, applications (such as Protege) usually implement their own
        // mappers to deal with specific application requirements.
    }
View Full Code Here


        URL url = getClass().getResource("/ontologies");
        assertNotNull(url);
        File file = new File(url.toURI());
        assertTrue(file.exists());
        assertTrue(file.isDirectory());
        OWLOntologyIRIMapper mapper = new AutoIRIMapper(file, true);

        IRI dummyiri = IRI.create("http://stanbol.apache.org/ontologies/peanuts/dummycharacters.owl");

        // Cleanup may be required if previous tests have failed.
        if (mapper.getDocumentIRI(dummyiri) != null) {
            new File(mapper.getDocumentIRI(dummyiri).toURI()).delete();
            ((AutoIRIMapper) mapper).update();
        }
        assertFalse(dummyiri.equals(mapper.getDocumentIRI(dummyiri)));

        // Create a new ontology in the test resources.
        OWLOntologyManager mgr = OWLOntologyManagerFactory.createOWLOntologyManager(null);
        OWLOntology o = mgr.createOntology(dummyiri);
        File f = new File(URI.create(url.toString() + "/dummycharacters.owl"));
        mgr.saveOntology(o, new WriterDocumentTarget(new FileWriter(f)));
        assertTrue(f.exists());

        ((AutoIRIMapper) mapper).update();
        // The old mapper should be able to locate the new ontology.
        assertFalse(dummyiri.equals(mapper.getDocumentIRI(dummyiri)));

        // A new mapper too
        OWLOntologyIRIMapper mapper2 = new AutoIRIMapper(new File(url.toURI()), true);
        assertFalse(dummyiri.equals(mapper2.getDocumentIRI(dummyiri)));

        // cleanup
        f.delete();
    }
View Full Code Here

        currentExplanation = Collections.emptySet();
        lhs2AxiomMap = new HashMap<OWLEntity, Set<OWLAxiom>>();
        entitiesByAxiomRHS = new HashMap<OWLAxiom, Set<OWLEntity>>();
        seedExtractor = new SeedExtractor();
        man = OWLManager.createOWLOntologyManager();
        man.addIRIMapper(new OWLOntologyIRIMapper() {
            public IRI getDocumentIRI(IRI ontologyIRI) {
                return ontologyIRI;
            }
        });
        mappedAxioms = new HashMap<OWLObject, Set<OWLAxiom>>();
View Full Code Here

    public OWLOntology loadRootOntologyImportsClosure(OWLOntologyManager manager) throws IOException, OWLOntologyCreationException {
        File rootOntologyFile = getRootOntologyFile();
        if(!rootOntologyFile.exists()) {
            throw new FileNotFoundException("Root ontology document file does not exist: " + rootOntologyFile.getAbsolutePath());
        }
        OWLOntologyIRIMapper mapper = getIRIMapper();
        try {
            manager.addIRIMapper(mapper);
            return manager.loadOntologyFromOntologyDocument(rootOntologyFile);
        }
        finally {
View Full Code Here

        InputStream ontologyStream = RefactoringTest.class
                .getResourceAsStream("/META-INF/test/testKReSOnt.owl");
        InputStream recipeStream = RefactoringTest.class.getResourceAsStream("/META-INF/test/rmi_config.owl");

        OWLOntologyIRIMapper map1 = new AutoIRIMapper(new File(RefactoringTest.class.getResource(
            "/META-INF/test/").toURI()), false);

        OWLOntologyManager mgr = OWLManager.createOWLOntologyManager();
        mgr.addIRIMapper(map1);
View Full Code Here

        URL url = getClass().getResource("/ontologies");
        assertNotNull(url);
        File file = new File(url.toURI());
        assertTrue(file.exists());
        assertTrue(file.isDirectory());
        OWLOntologyIRIMapper mapper = new AutoIRIMapper(file, true);

        IRI dummyiri = IRI.create("http://stanbol.apache.org/ontologies/peanuts/dummycharacters.owl");

        // Cleanup may be required if previous tests have failed.
        if (mapper.getDocumentIRI(dummyiri) != null) {
            new File(mapper.getDocumentIRI(dummyiri).toURI()).delete();
            ((AutoIRIMapper) mapper).update();
        }
        assertFalse(dummyiri.equals(mapper.getDocumentIRI(dummyiri)));

        // Create a new ontology in the test resources.
        OWLOntologyManager mgr = OWLOntologyManagerFactory.createOWLOntologyManager(null);
        OWLOntology o = mgr.createOntology(dummyiri);
        File f = new File(URI.create(url.toString() + "/dummycharacters.owl"));
        mgr.saveOntology(o, new WriterDocumentTarget(new FileWriter(f)));
        assertTrue(f.exists());

        ((AutoIRIMapper) mapper).update();
        // The old mapper should be able to locate the new ontology.
        assertFalse(dummyiri.equals(mapper.getDocumentIRI(dummyiri)));

        // A new mapper too
        OWLOntologyIRIMapper mapper2 = new AutoIRIMapper(new File(url.toURI()), true);
        assertFalse(dummyiri.equals(mapper2.getDocumentIRI(dummyiri)));

        // cleanup
        f.delete();
    }
View Full Code Here

            // Setup local IRI mappings
            OWLOntologyManager mgr = OWLManager.createOWLOntologyManager();
            // FIXME : awful, remove as soon as we can
            URL u = getClass().getResource("/rmi.owl");
            OWLOntologyIRIMapper mapper1, mapper2;
            try {
                mapper1 = new SimpleIRIMapper(
                        IRI.create("http://ontologydesignpatterns.org/ont/iks/kres/rmi.owl"), IRI.create(u));
                mapper2 = new SimpleIRIMapper(
                        IRI.create("http://ontologydesignpatterns.org/ont/iks/kres/rmi_config.owl"),
View Full Code Here

TOP

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

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.