简体   繁体   English

如何将猫头鹰类导入日食

[英]How to import owl classes into the eclipse

I want to import and list semantic web (owl) file's classes into the eclipse. 我想将语义Web(猫头鹰)文件的类导入并列出到eclipse中。 I did import pellet and protege library my eclipse program but still I see force close my android project. 我确实导入了我的eclipse程序的pellet和protege库,但是仍然看到强制关闭我的android项目。 nothing red line or wrong code because I used same codes in net beans. 没有红线或错误代码,因为我在Net Bean中使用了相同的代码。 my codes is below.. 我的代码在下面。

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

I have mistake this code segment 我把这个代码段弄错了

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

There is no ontology in the URL http://www.emkarhafriyat.com/owlex.owl (404) therefore nothing can be loaded by m.loadOntologyFromOntologyDocument(Ont_Base_IRI); URL http://www.emkarhafriyat.com/owlex.owl(404 )中没有本体,因此m.loadOntologyFromOntologyDocument(Ont_Base_IRI);无法加载任何内容m.loadOntologyFromOntologyDocument(Ont_Base_IRI); and you get an error. 你会得到一个错误。

To fix it, you should either expose your OWL file at the specified URL or to load the OWL file from local. 要修复它,您应该在指定的URL中暴露OWL文件,或者从本地加载OWL文件。 You can do it this way: 您可以这样操作:

//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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM