java - owlexplanation with Hermit reasoner -
i trying utilize hermit reasoner check consistency. hermit reasoner default not provide justification/explanations inconsistencies.
edited version:: i'm trying owlreasoner, still throws error.
import java.util.set; import org.semanticweb.hermit.reasoner; import org.semanticweb.owl.explanation.api.explanation; import org.semanticweb.owl.explanation.api.explanationgeneratorfactory; import org.semanticweb.owl.explanation.api.explanationmanager; import org.semanticweb.owl.explanation.impl.blackbox.checker.inconsistentontologyexplanationgeneratorfactory; import org.semanticweb.owlapi.apibinding.owlmanager; import org.semanticweb.owlapi.model.iri; import org.semanticweb.owlapi.model.owlaxiom; import org.semanticweb.owlapi.model.owlclass; import org.semanticweb.owlapi.model.owlontology; import org.semanticweb.owlapi.model.owlontologymanager; import org.semanticweb.owlapi.reasoner.node; import org.semanticweb.owlapi.reasoner.owlreasoner; import org.semanticweb.owl.explanation.api.explanationgenerator; import org.semanticweb.owlapi.model.owldatafactory; import org.semanticweb.owlapi.model.owlnamedindividual; import org.semanticweb.owlapi.model.owlontologycreationexception; import org.semanticweb.owlapi.reasoner.owlreasonerfactory; public class consistencychecker { public static void main(string[] args) throws exception { owlontologymanager m=owlmanager.createowlontologymanager(); owlontology o=m.loadontologyfromontologydocument(iri.create("http://www.cs.ox.ac.uk/isg/ontologies/uid/00793.owl")); // reasoner hermit=new reasoner(o); owlreasoner owlreasoner=new reasoner.reasonerfactory().createreasoner(o); system.out.println(owlreasoner.isconsistent()); //system.out.println(hermit.isconsistent()); //---------------------------- copied example--------- owldatafactory df = m.getowldatafactory(); owlclass testclass = df.getowlclass(iri.create("urn:test#testclass")); m.addaxiom(o, df.getowlsubclassofaxiom(testclass, df.getowlnothing())); owlnamedindividual individual = df.getowlnamedindividual(iri .create("urn:test#testindividual")); m.addaxiom(o, df.getowlclassassertionaxiom(testclass, individual)); //---------------------------------------------------------- node<owlclass> unsatisfiableclasses = owlreasoner.getunsatisfiableclasses(); //node<owlclass> unsatisfiableclasses = hermit.getunsatisfiableclasses(); (owlclass owlclass : unsatisfiableclasses) { system.out.println(owlclass.getiri()); } //----------------------------- explanationgeneratorfactory<owlaxiom> genfac = explanationmanager.createexplanationgeneratorfactory((owlreasonerfactory) owlreasoner); explanationgenerator<owlaxiom> gen = genfac.createexplanationgenerator(o); //------------------------- inconsistentontologyexplanationgeneratorfactory igf = new inconsistentontologyexplanationgeneratorfactory((owlreasonerfactory) owlreasoner, 10000); //inconsistentontologyexplanationgeneratorfactory igf = new inconsistentontologyexplanationgeneratorfactory((owlreasonerfactory) hermit, 10000); explanationgenerator<owlaxiom> generator = igf.createexplanationgenerator(o); owlaxiom entailment = df.getowlclassassertionaxiom(df.getowlnothing(), individual); //------------- set<explanation<owlaxiom>> expl = gen.getexplanations(entailment, 5); //------------ system.out.println("explanation " + generator.getexplanations(entailment, 5)); } }
the output
true http://www.w3.org/2002/07/owl#nothing http://www.co-ode.org/ontologies/pizza/pizza.owl#cheeseyvegetabletopping http://www.co-ode.org/ontologies/pizza/pizza.owl#icecream exception in thread "main" java.lang.classcastexception: org.semanticweb.hermit.reasoner cannot cast org.semanticweb.owlapi.reasoner.owlreasonerfactory @ consistencychecker.main(consistencychecker.java:82)
any help in integrating owlexplanation api [1] hermit reasoner/owlreasoner appreciated.
[1]https://github.com/matthewhorridge/owlexplanation
the error because you're casting owlreasoner
owlreasonerfactory
.
the owlreasonerfactory
hermit 1 you've used few lines above:
new reasoner.reasonerfactory()
java eclipse owl ontology owl-api
No comments:
Post a Comment