简体   繁体   中英

Insert data into OWL ontology

I have a custom OWL ontology and I uploaded into my model like this:

    OntModel=ModelFactory.createOntologyModel();

    InputStream in = FileManager.get().open(urlFile);   
    model.read(in,"");

I get the whole ontology into my model. Now I don't know how to add some data into that model. The data that want to insert must be appropriate with that ontology that I uploaded.

Can you give some hints or markups to do that? I'm very lost here.

You might find the Model API tutorial useful for learning how to work with a Jena model. Further, the Jena javadocs are always a good reference.

The tutorial will show you how to add data to your Model.

I'm not sure what you mean by "appropriate" with the ontology. You can just start stating facts in RDF; if you state something that contradicts your ontology, it's state is merely inconsistent, but things will still work.

Understanding what it means for the model to be inconsistent, to have unsatisfiable classes, and other OWL (DL really) specific constructs, you should review the DL handbook. Chapter 2 is particularly good.

If by appropriate you mean integrity constraints akin to what you'd have in a relational system, well, it doesn't work like that. The open world assumption makes that a bit tricky, you can't really get the behavior you might expect without "closing" the world. There's a good discussion of this on Pellet's ICV page , and implementation of which is currently in Stardog .

Hope that helps.

If I understood correctly, you wanted to add data into model.

You can add statements to the model as

 model.add(statement);

or another model itself as

 model.add(newModel);

Hope this will help you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM