com.hp.hpl.jena.ontology.OntModelSpec Java Examples

The following examples show how to use com.hp.hpl.jena.ontology.OntModelSpec. 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: 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 #2
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 #3
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 #4
Source File: WP2ModelFactory.java    From GeoTriples with Apache License 2.0 3 votes vote down vote up
/**
 * <p>
 * Answer a new ontology model which will process in-memory models of
 * ontologies expressed the default ontology language (OWL).
 * The default document manager
 * will be used to load the ontology's included documents.
 * </p>
 *
 * @param spec An ontology model specification that defines the language and reasoner to use
 * @param maker A model maker that is used to get the initial store for the ontology (unless
 * the base model is given),
 * and create addtional stores for the models in the imports closure
 * @param base The base model, which contains the contents of the ontology to be processed
 * @return A new ontology model
 * @see OntModelSpec
 */
public static OntModel createOntologyModel( OntModelSpec spec, ModelMaker maker, Model base ) {
    OntModelSpec _spec = new OntModelSpec( spec );
    _spec.setImportModelMaker( maker );

    return createOntologyModel( _spec, base );
}
 
Example #5
Source File: WP2ModelFactory.java    From GeoTriples with Apache License 2.0 2 votes vote down vote up
/**
 * <p>
 * Answer a new ontology model which will process in-memory models of
 * ontologies in the given language.
 * The default document manager
 * will be used to load the ontology's included documents.
 * </p>
 *
 * @param languageURI The URI specifying the ontology language we want to process
 * @return A new ontology model
 * @see OntModelSpec#getDefaultSpec
 */
public static OntModel createOntologyModel( String languageURI ) {
    return createOntologyModel( OntModelSpec.getDefaultSpec( languageURI ), null );
}
 
Example #6
Source File: WP2ModelFactory.java    From GeoTriples with Apache License 2.0 2 votes vote down vote up
/**
 * <p>
 * Answer a new ontology model, constructed according to the given ontology model specification,
 * and starting with the ontology data in the given model.
 * </p>
 *
 * @param spec An ontology model specification object, that will be used to construct the ontology
 * model with different options of ontology language, reasoner, document manager and storage model
 * @param base An existing model to treat as an ontology model, or null.
 * @return A new ontology model
 * @see OntModelSpec
 */
public static OntModel createOntologyModel( OntModelSpec spec, Model base ) {
    return new OntModelImpl( spec, base );
}
 
Example #7
Source File: WP2ModelFactory.java    From GeoTriples with Apache License 2.0 2 votes vote down vote up
/**
 * Answer a new ontology model constructed according to the specification, which includes
 * a ModelMaker which will create the necessary base model.
*/
public static OntModel createOntologyModel( OntModelSpec spec )
    { return new OntModelImpl( spec ); }
 
Example #8
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);
}