Java Code Examples for com.hp.hpl.jena.rdf.model.ModelFactory#createOntologyModel()

The following examples show how to use com.hp.hpl.jena.rdf.model.ModelFactory#createOntologyModel() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OntologyLoader.java    From GeoTriples with Apache License 2.0 5 votes vote down vote up
/**
 * load the ontology from the specified file
 */
public void load() {
		    
    model = ModelFactory.createOntologyModel();
    try {
		model.read(new FileInputStream(ontologyFilePath), "http://data.linkedeodata.eu/natura-2000-de/");
	} catch (FileNotFoundException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}
 
Example 2
Source File: RDFFileManager.java    From Benchmark with GNU General Public License v3.0 5 votes vote down vote up
private static void loadOntology(Dataset dataset) {
	Model ssnBase = FileManager.get().loadModel(ontologyDirectory + "ssn.owl");
	Model ssnInf = ModelFactory.createOntologyModel(ontoSpec, ssnBase);
	dataset.addNamedModel(ssnPrefix, ssnInf);

	Model owlService = FileManager.get().loadModel(ontologyDirectory + "Service.owl");
	Model owlServiceInf = ModelFactory.createOntologyModel(ontoSpec, owlService);
	dataset.addNamedModel(owlsPrefix, owlServiceInf);

	Model owlGrounding = FileManager.get().loadModel(ontologyDirectory + "Grounding.owl");
	Model owlGroundingInf = ModelFactory.createOntologyModel(ontoSpec, owlGrounding);
	dataset.addNamedModel(owlsPrefix, owlGroundingInf);

	Model owlProcess = FileManager.get().loadModel(ontologyDirectory + "Process.owl");
	Model owlProcessInf = ModelFactory.createOntologyModel(ontoSpec, owlProcess);
	dataset.addNamedModel(owlsPrefix, owlProcessInf);

	Model owlProfile = FileManager.get().loadModel(ontologyDirectory + "Profile.owl");
	Model owlProfileInf = ModelFactory.createOntologyModel(ontoSpec, owlProfile);
	dataset.addNamedModel(owlsPrefix, owlProfileInf);

	Model cesBase = FileManager.get().loadModel(ontologyDirectory + "ces.n3");
	Model cesInf = ModelFactory.createOntologyModel(ontoSpec, cesBase);
	dataset.addNamedModel(cesPrefix, cesInf);

	Model ctBase = FileManager.get().loadModel(ontologyDirectory + "city.n3");
	Model ctInf = ModelFactory.createOntologyModel(ontoSpec, ctBase);
	dataset.addNamedModel(ctPrefix, ctInf);

	// FileManager.get().r(dataset.getNamedModel(ssnPrefix),
	// ModelFactory.createInfModel(ReasonerRegistry.getRDFSReasoner(), ssnBase));
	// FileManager.get().readModel(dataset.getNamedModel(owlPrefix), ontologyDirectory + "Service.owl");
	//
	// FileManager.get().readModel(dataset.getNamedModel(owlPrefix), ontologyDirectory + "Grounding.owl");
	// FileManager.get().readModel(dataset.getNamedModel(owlPrefix), ontologyDirectory + "Process.owl");
	// FileManager.get().readModel(dataset.getNamedModel(owlPrefix), ontologyDirectory + "Profile.owl");
	// FileManager.get().readModel(dataset.getNamedModel(cesPrefix), ontologyDirectory + "ces.n3");
}
 
Example 3
Source File: Lexicon.java    From nadia with Apache License 2.0 5 votes vote down vote up
private void load(URL ontologyURL){
		try {
		    model = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM);
		    //String file="file:///"+System.getProperty("user.dir")+"/ont/lexicon.owl";
		    String file=ontologyURL.toExternalForm();
		    model.read(file,"RDF/XML");
		} catch (Exception e) {
			logger.warning("Ontology could not be loaded");
			e.printStackTrace();
		}
}
 
Example 4
Source File: JenaUtils.java    From xcurator with Apache License 2.0 4 votes vote down vote up
public static OntModel loadOntology(InputStream is) {
    OntModel m = ModelFactory.createOntologyModel(OntModelSpec.OWL_LITE_MEM);
    m.read(is, null);
    return m;
}
 
Example 5
Source File: OwlReader.java    From EventCoreference with Apache License 2.0 4 votes vote down vote up
static void readOwlFile (String pathToOwlFile) {
        OntModel ontologyModel =
                ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, null);
        ontologyModel.read(pathToOwlFile, "RDF/XML-ABBREV");
       // OntClass myClass = ontologyModel.getOntClass("namespace+className");

        OntClass myClass = ontologyModel.getOntClass(ResourcesUri.nwr+"domain-ontology#Motion");
        System.out.println("myClass.toString() = " + myClass.toString());
        System.out.println("myClass.getSuperClass().toString() = " + myClass.getSuperClass().toString());

        //List list =
              //  namedHierarchyRoots(ontologyModel);


       Iterator i = ontologyModel.listHierarchyRootClasses()
                .filterDrop( new Filter() {
                    public boolean accept( Object o ) {
                        return ((Resource) o).isAnon();
                    }} ); ///get all top nodes and excludes anonymous classes

       // Iterator i = ontologyModel.listHierarchyRootClasses();
        while (i.hasNext()) {
            System.out.println(i.next().toString());
/*            OntClass ontClass = ontologyModel.getOntClass(i.next().toString());
            if (ontClass.hasSubClass()) {

            }*/
        }

        String q = createSparql("event", "<http://www.newsreader-project.eu/domain-ontology#Motion>");
        System.out.println("q = " + q);
        QueryExecution qe = QueryExecutionFactory.create(q,
                ontologyModel);
        for (ResultSet rs = qe.execSelect() ; rs.hasNext() ; ) {
            QuerySolution binding = rs.nextSolution();
            System.out.println("binding = " + binding.toString());
            System.out.println("Event: " + binding.get("event"));
        }

        ontologyModel.close();
    }
 
Example 6
Source File: OWLJavaFileGenerator.java    From anno4j with Apache License 2.0 2 votes vote down vote up
/**
 * Initializes the generator with an Anno4j instance which connected repository
 * will receive the ontology information (including inferred statements) after a call
 * to {@link #build()} or {@link #generateJavaFiles(OntGenerationConfig, File)}.
 * @param anno4j The Anno4j instance that will receive ontology information.
 */
public OWLJavaFileGenerator(Anno4j anno4j) {
    this.anno4j = anno4j;

    model = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
}
 
Example 7
Source File: D2RQReader.java    From GeoTriples with Apache License 2.0 2 votes vote down vote up
/**
 * Constructs a new MapParser from a Jena model containing the RDF statements
 * from a D2RQ mapping file.
 * @param mapModel a Jena model containing the RDF statements from a D2RQ mapping file
 * @param baseURI used for relative URI patterns
 */
public D2RQReader(Model mapModel, String baseURI) {
	this.model = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, mapModel);
	this.baseURI = absolutizeURI(baseURI);
}