1

セマンティック Web (フクロウ) ファイルのクラスを Eclipse にインポートして一覧表示したいと考えています。私はEclipseプログラムにペレットとプロテジライブラリをインポートしましたが、それでも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");
4

1 に答える 1

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);
于 2013-01-17T13:03:45.790 に答える