如何将owl类导入eclipse

时间:2013-01-17 09:09:44

标签: android eclipse class owl

我想导入并将语义网(owl)文件的类列入eclipse。我确实导入了pellet和protege库我的eclipse程序,但我仍然看到force关闭我的android项目。没有红线或错误的代码,因为我在网络豆中使用相同的代码。我的代码在下面..

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

1 个答案:

答案 0 :(得分:0)

网址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);