OWL API 4.1.3を使用して、大きくない私のオントロジーをロードしました。推測された情報を使う必要があるので、私はHermit 1.3.8.413ライブラリを使って推論を行った。次のコードは私がどのようにしたかを示しています。OWL APIを使用したオントロジーの推論
public class ReasonRDF {
public static void main(String[] args) throws OWLOntologyCreationException, OWLOntologyStorageException {
readRDF("C:/Users/workspace/Ontology_matching/NVDB_Matching_v18_H_4_1_CONVERTYING/results/NewInstantiated/owl/OSM1.owl");
}
public static void readRDF(String address) throws OWLOntologyCreationException, OWLOntologyStorageException{
OWLOntologyManager manager =OWLManager.createOWLOntologyManager();
File file = new File (address);
OWLOntology ont = manager.loadOntologyFromOntologyDocument(IRI.create(file));
System.out.println("Ontology Loaded...");
System.out.println("Logical IRI : " + ont.getOntologyID());
System.out.println("Format : " + manager.getOntologyFormat(ont));
System.out.println("Runtime memory: " + Runtime.getRuntime().totalMemory());
ReasonerFactory reasonerFactory = new ReasonerFactory();
ConsoleProgressMonitor progressMonitor = new ConsoleProgressMonitor();
Configuration config = new Configuration();
config.ignoreUnsupportedDatatypes=true;
config.reasonerProgressMonitor= progressMonitor;
OWLReasoner reasoner = reasonerFactory.createReasoner(ont, config);
long t0 = System.nanoTime();
System.out.println("Starting to add axiom generators");
OWLDataFactory datafactory = manager.getOWLDataFactory();
List<InferredAxiomGenerator<? extends OWLAxiom>> inferredAxioms = new ArrayList<InferredAxiomGenerator<? extends OWLAxiom>>();
//inferredAxioms.add(new InferredSubClassAxiomGenerator());
inferredAxioms.add(new InferredClassAssertionAxiomGenerator());
//inferredAxioms.add(new InferredDataPropertyCharacteristicAxiomGenerator());
//inferredAxioms.add(new InferredObjectPropertyCharacteristicAxiomGenerator());
//inferredAxioms.add(new InferredEquivalentClassAxiomGenerator());
//inferredAxioms.add(new InferredPropertyAssertionGenerator());
//inferredAxioms.add(new InferredInverseObjectPropertiesAxiomGenerator());
inferredAxioms.add(new InferredSubDataPropertyAxiomGenerator());
inferredAxioms.add(new InferredSubObjectPropertyAxiomGenerator());
System.out.println("finished adding axiom generators");
// List<InferredIndividualAxiomGenerator<? extends OWLIndividualAxiom>> individualAxioms= new ArrayList<InferredIndividualAxiomGenerator<? extends OWLIndividualAxiom>>();
// inferredAxioms.addAll(individualAxioms);
// for writing inferred axioms to the new ontology
OWLOntology infOnt = manager.createOntology(IRI.create(ont.getOntologyID().getOntologyIRI().get()+"_inferred"));
// use generator and reasoner to infer some axioms
System.out.println("Starting to infer");
InferredOntologyGenerator iog = new InferredOntologyGenerator(reasoner, inferredAxioms);
//InferredOntologyGenerator iog = new InferredOntologyGenerator(reasoner);
System.out.println("Inferrence is over");
System.out.println("Storing the results");
iog.fillOntology(datafactory,infOnt);
System.out.println("Results are stored");
long elapsed_time = System.nanoTime()-t0;
System.out.println(elapsed_time);
// save the ontology
manager.saveOntology(infOnt, IRI.create("file:///C:/Users/ontologies/NVDB4_test.rdf"));
}
}
エラーは発生しませんが、推論されたオントロジーを新しいファイルに保存するために必要です。実際には2日後でさえも仕事を完了しません。私のIDEはEclipse EEであり、このアプリケーションを実行するために6〜12 GBのメモリが与えられています。 私のコードやオントロジーに問題が見つかりません。
誰かが最適化を提案したり、より良い実装方法や別のAPIを提案できますか?
hereは、誰かがテストしたい場合のための私のオントロジーです。
オントロジ内の用語の数とオントロジー内の関係の数を明確にすることはできますか?また、最も多くの時間を費やした行を知っていますか? –
私のオントロジーには、個人、SWRL、不動産の陳列、GCA、閉包の公理を含む15426の公理があります。最も時間のかかる部分は保存段階のようです。 – msc87