1

私は、Jena を使用してオントロジーを自動的にインスタンス化する方法に取り組んでいます。一連のデータから発見された概念をインスタンス化することに興味があります。

私の問題は、オントロジーの 1 つの概念をインスタンス化するだけでよい場合があることです。Jena では、オントロジーをインスタンス化するために完全な Statement が必要なので、私は混乱しています。

私が次のオントロジーを持っていると仮定します。

ここに画像の説明を入力

たとえば、オントロジーで 1 つの概念のみをインスタンス化するステートメントは何でしょうEventTypeか?

Statementオントロジーをインスタンス化する必要がありますか?

または私のオントロジーは十分に表現力がありませんか?

版 : My Jena Code

public static void manageOntologies() throws FileNotFoundException{     

    int i,inFrame, lineSize;
    int frameNum = 0;

    Individual individu;
    Resource   resource;
    Statement  statement;
    OntModel   domainModel;

    Vector<String> lines = readFile("data/Trace.dat");

    String[] parts = null;
    String   event = null;

    domainModel = ModelFactory.createOntologyModel(ProfileRegistry.OWL_DL_LANG);
    domainModel.read((new FileInputStream(ontopath)), null);

    lineSize = lines.size(); 

    for(i = 0; i < lineSize; i++){
        parts = lines.elementAt(i).split(" ");
        event = parts[parts.length - 1];            
        resource = domainModel.createResource(xmlbase + "frame" + frameNum);//, domainModel.getOntClass(xmlbase + "Event"));
        domainModel.add(resource, RDF.type, domainModel.getOntClass("Event"));

    }

    System.out.println("Numbre de frame = " + frameNum);

    domainModel.write(System.out);
}

そして、ここに問題が発生しました

Exception in thread "main" java.lang.NullPointerException
    at com.hp.hpl.jena.rdf.model.impl.ModelCom.add(ModelCom.java:929)
    at soctrace.Intology.manageOntologies(Intology.java:87) -- domainModel.add(...)
    at soctrace.Intology.main(Intology.java:38)

第 2 版 : 私の OWL/XML コード

<?xml version="1.0"?>
<!DOCTYPE rdf:RDF [
    <!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" >
    <!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" >
    <!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
    <!ENTITY tima "http://www.soctrace.org/ontologies/tima.owl#" >
]>


<rdf:RDF xmlns="http://www.w3.org/2002/07/owl#"
     xml:base="http://www.w3.org/2002/07/owl"
     xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
     xmlns:tima="http://www.soctrace.org/ontologies/tima.owl#"
     xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
    <Ontology rdf:about="http://www.soctrace.org/ontologies/tima.owl">       
</Ontology>


<!-- http://www.soctrace.org/ontologies/tima.owl#Event -->

<Class rdf:about="&tima;Event">
    <rdfs:subClassOf rdf:resource="http://www.w3.org/2002/07/owl#Thing"/>
</Class>



<!-- http://www.soctrace.org/ontologies/tima.owl#EventDuration -->

<Class rdf:about="&tima;EventDuration">
    <rdfs:subClassOf rdf:resource="&tima;ValuePartition"/>
</Class>



<!-- http://www.soctrace.org/ontologies/tima.owl#EventType -->

<Class rdf:about="&tima;EventType">
    <rdfs:subClassOf rdf:resource="&tima;ValuePartition"/>
</Class>



<!-- http://www.soctrace.org/ontologies/tima.owl#ValuePartition -->

    <Class rdf:about="&tima;ValuePartition"/>
</rdf:RDF>

返信ありがとうございます。

4

2 に答える 2

2

RDF では、個々の用語や概念ではなく、ステートメントを格納することは正しいです。ただし、すべてのものには型がrdfs:Resourceありowl:Individualますowl:Class。したがって、常にフォームのステートメントを介して何かを追加しthing rdf:type Type、適切なタイプを選択するだけです。

この場合、おそらくEventTypeクラスですか?その場合:

Resource eventTypeResource = model.createResource(eventTypeURI);
model.add(eventTypeResource, RDF.type, OWL.class);

ただし、これは使用できる一般的なパターンです。

Resource eventTypeResource = model.createResource(eventTypeURI, OWL.class);

または、Jena オントロジー API を使用することをお勧めします。

OntClass eventTypeResource = ontModel.createClass(eventTypeURI);

(OntClassはまだResourceですが、いくつかの非常に便利なメソッドが追加されています)

Jena は、オントロジー api の優れた紹介を提供します。

于 2012-06-14T11:02:40.200 に答える