私はフクロウのAPIで簡単なことをしようとしています。このために、オントロジーを作成し、いくつかのクラスと SubClassOf Axioms を作成しました。この後、Reasoner Hermit を使って何かをしようとします。しかし、hermits メソッドの 1 つを呼び出すと、Null Pointer Exception が発生します。これは私の実際の例です:
public class Main {
static OWLOntologyManager manager = null;
static IRI ontologyIRI = null;
static IRI documentIRI = null;
static OWLOntology ontology = null;
static OWLDataFactory factory = null;
static OWLReasoner hermit = null;
static HashMap<String, HashSet<String>> keywords = new HashMap<String, HashSet<String>>();
public static void main(String[] args) throws IOException, OWLException{
manager = OWLManager.createOWLOntologyManager();
ontologyIRI = IRI.create("http://www.someurl.com/myOnto.owl");
documentIRI = IRI.create("file:/src/main/resources.xml");
SimpleIRIMapper mapper = new SimpleIRIMapper(ontologyIRI, documentIRI);
manager.addIRIMapper(mapper);
ontology = manager.createOntology(ontologyIRI);
factory = manager.getOWLDataFactory();
OWLClass main = factory.getOWLClass(
IRI.create(ontologyIRI + "#main"));
OWLClass clsA = factory.getOWLClass(
IRI.create(ontologyIRI + "#test"));
OWLAxiom axiom = factory.getOWLSubClassOfAxiom(clsA, main);
AddAxiom addAxiom = new AddAxiom(ontology, axiom);
manager.applyChange(addAxiom);
//I insert some more classes and axioms here
ReasonerFactory fac = new ReasonerFactory();
hermit = fac.createReasoner(ontology);
// Print the hierarchy, this works fine
HirarchyPrinter hp = new HirarchyPrinter(manager, hermit);
hp.printHierarchy(ontology, clazz);
//now here I want to access the data, e.g. starting with this call:
hermit.getSubClasses(main, false);
}
しかし、常に例外が発生し、常に getTableau 呼び出しで終了します
Exception in thread "main" java.lang.NullPointerException
at org.semanticweb.HermiT.Reasoner.getTableau(Unknown Source)
at org.semanticweb.HermiT.Reasoner.isConsistent(Unknown Source)
at org.semanticweb.HermiT.Reasoner.throwInconsistentOntologyExceptionIfNecessary(Unknown Source)
at org.semanticweb.HermiT.Reasoner.checkPreConditions(Unknown Source)
at org.semanticweb.HermiT.Reasoner.getHierarchyNode(Unknown Source)
at org.semanticweb.HermiT.Reasoner.getSubClasses(Unknown Source)
at main.java.Main.main(Main.java:93)
この例外の原因がわかりません。同様のケースがどこにも見つかりませんでした。
こんにちは、ダニエル