[英]How to import owl classes into the eclipse
我想將語義Web(貓頭鷹)文件的類導入並列出到eclipse中。 我確實導入了我的eclipse程序的pellet和protege庫,但是仍然看到強制關閉我的android項目。 沒有紅線或錯誤代碼,因為我在Net Bean中使用了相同的代碼。 我的代碼在下面。
public static final IRI localLocation_IRI = IRI.create("file:c:///rdfex.owl");
public static final IRI Ont_Base_IRI = IRI.create("http://www.emkarhafriyat.com/owlex.owl");
OWLOntologyManager m = OWLManager.createOWLOntologyManager();
OWLDataFactory f = OWLManager.getOWLDataFactory();
OWLOntology o = null;
public void testAddAxioms() {
try {
o = m.loadOntologyFromOntologyDocument(Ont_Base_IRI);
OWLClass clsA = f.getOWLClass(IRI.create(Ont_Base_IRI + "#ClassA"));
OWLClass clsB = f.getOWLClass(IRI.create(Ont_Base_IRI + "#ClassB"));
// Now create the axiom
OWLAxiom ax1 = f.getOWLSubClassOfAxiom(clsA, clsB);
// add the axiom to the ontology.
AddAxiom addAxiom1 = new AddAxiom(o, ax1);
// We now use the manager to apply the change
m.applyChange(addAxiom1);
// print all classes
for (OWLClass cls : o.getClassesInSignature()) {
EditText edit = (EditText) findViewById(R.id.editText1);
edit.setText((CharSequence) cls);
}
m.removeOntology(o);
} catch (Exception e) {
EditText edit = (EditText) findViewById(R.id.editText1);
edit.setText("Not successfull");
}
}
我把這個代碼段弄錯了
public static final IRI localLocation_IRI = IRI.create("file:c:///rdfex.owl");
public static final IRI Ont_Base_IRI = IRI.create("http://www.emkarhafriyat.com/owlex.owl");
URL http://www.emkarhafriyat.com/owlex.owl(404 )中沒有本體,因此m.loadOntologyFromOntologyDocument(Ont_Base_IRI);
無法加載任何內容m.loadOntologyFromOntologyDocument(Ont_Base_IRI);
你會得到一個錯誤。
要修復它,您應該在指定的URL中暴露OWL文件,或者從本地加載OWL文件。 您可以這樣操作:
//Create the file object
File file = new File("/your/local/path/example.owl");
// Now load the local copy of the ontology
OWLOntology yourOntology = manager.loadOntologyFromOntologyDocument(file);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.