2013-01-17 60 views
1

我想導入並列出eclipse中的語義web(owl)文件的類。我沒有導入小球和保護庫我的eclipse程序,但仍然看到強制關閉我的android項目。沒有紅線或錯誤的代碼,因爲我在net beans中使用了相同的代碼。我的代碼低於..如何將貓頭鷹類導入eclipse

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"); 

回答

0

有一個在URL http://www.emkarhafriyat.com/owlex.owl(404),因此沒有任何東西可以通過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); 
+0

感謝您的回答,但我沒有做任何本地路徑,也沒有URL。本地路徑應該是電話路徑? – freemat3

+0

是的,我想你可以使用電話路徑(本地路徑)來導入它。 – loopasam