简体   繁体   中英

How to check for ontology consistency using java

I am using Ontology for recognition of user activities....I have an ontology(OWL) consisting of the various classes i will be using along with the object properties.....

i am new to ontology and am confused even after readin a lot about it....
What i understand is that a class is defined in relation to another class using various propeties...so is there anyway i can check whether the objects of a particular class are anyway related to another class..What i wanna ask is how do I check whether an ABox is consistent with the terminological part of the ontology(the TBox as i understand).....

i have used protege for making my ontology and also tried using jena and pellet reasoner along with its GUI version SWOOP to check the consistency.....

I am completely confused and have no clue what to use...

SWOOP is pretty outdated, if you're going to use a GUI, I recommend you stick with Protoge 4. For information on using Pellet, there's a pretty good tutorial online .

I recommend using OWLAPI over Jena if you're going to work with OWL programmatically. Jena is a more RDF-centric API while OWLAPI is designed for OWL, so you'll find it easier to work with when you're doing OWL related stuff. That said, Jena is vastly more featureful.

This is how you can perform consistency checking with the Java OWL API:

/*Load your ontology from a local file and do the initialisations*/
File inputfile = new File("ontologyPath");
OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); ;
OWLDataFactory dataFactory = manager.getOWLDataFactory();
OWLOntology yourOntology = manager.loadOntologyFromOntologyDocument(inputfile);
IRI ontologyIRI = yourOntology.getOntologyID().getOntologyIRI();  

/* Load a reasoner, the default one that comes with the OWL API is HermiT.
   However, You can use other reasoners, such as Fact++ or Pellet, by 
   downloading their libraries and adding them to your project build path */ 
OWLReasonerFactory reasonerFactory = new Reasoner.ReasonerFactory();
OWLReasonerreasoner = reasonerFactory.createReasoner(yourOntology);

/* Perform consistency check */ 
boolean consistency = reasoner.isConsistent();

Also check out the examples on the OWL API website.

Berkan

I have used the Jena API to deal with Ontologies created by Protege before. Jena is, admittedly confusing. However, these are resources that I used to help figure it out:

In order to figure out how it worked, we did some spikes where we created a very simple OWL file and wrote some Java using Jena to see how we would be able to get what we needed. The code was throw-away, but it allowed us to learn a bit about OWL files and the Jena API in an idealized context.

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