私は多くの個人とのオントロジーを持っており、Jena 推論を使用してそれらに関する情報を取得しています。私の目標は、そのルール内の特定の情報に基づいて新しい個人を作成し、それらにプロパティを割り当てることです。個体に名前を付ける必要はありませんが、型が必要で、いくつかのプロパティの一部である必要があります。現時点では、(メーリング リストへの投稿の助けを借りて) 匿名の個人を作成できますが、指定できるのは 1 つの型または 1 つのプロパティのみです。
これが私の問題の小さな例です。私のルールは次のようになります (オントロジーと推論された結果は下部にあります):
[test2: (?X rdf:type NS:Test1) ->
[(?Y rdf:type NS:Test2) <- makeSkolem(?Y, ?X)]]
これは、Test1 個体が見つかると、新しい空のノードが作成され、そのノードにタイプ Test2 が与えられることを意味します。正常に動作しますが、この新しい個体に分類と ?X (Test1 個体) へのポインター (プロパティ) を与えたいと考えています。
次のようなものは機能しません。「後方規則では先頭句が 1 つしか許可されない」ためです。ただし、その句のすべての句は完全に正常に機能します。
[test2: (?X rdf:type NS:Test1) ->
[(?Y rdf:type NS:Test2), (?Y NS:hasClassification 'test'), <- makeSkolem(?Y, ?X)]]
これは私のオントロジーです:
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns="file:/Test#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" >
<rdf:Description rdf:about="file:/Test#hasClassification">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#DatatypeProperty"/>
</rdf:Description>
<rdf:Description rdf:about="file:/Test#TestProp">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#ObjectProperty"/>
</rdf:Description>
<rdf:Description rdf:about="file:/Test#testInd">
<rdf:type rdf:resource="file:/Test#Test1"/>
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
</rdf:Description>
<rdf:Description rdf:about="file:/Test#testInd2">
<rdf:type rdf:resource="file:/Test#Test1"/>
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
</rdf:Description>
<rdf:Description rdf:about="file:/Test#Test1">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/>
</rdf:Description>
<rdf:Description rdf:about="file:/Test#Test2">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/>
</rdf:Description>
<rdf:Description rdf:about="file:/Test">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Ontology"/>
</rdf:Description>
</rdf:RDF>
これは最初のルールの結果です (IDA0
を持つ空白のノードA1
が新しい個体です)。
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns="file:/Test#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" >
<rdf:Description rdf:about="file:/Test#hasClassification">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#DatatypeProperty"/>
</rdf:Description>
<rdf:Description rdf:nodeID="A0">
<rdf:type rdf:resource="file:/Test#Test2"/>
</rdf:Description>
<rdf:Description rdf:about="file:/Test#TestProp">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#ObjectProperty"/>
</rdf:Description>
<rdf:Description rdf:about="file:/Test#testInd">
<rdf:type rdf:resource="file:/Test#Test1"/>
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
</rdf:Description>
<rdf:Description rdf:about="file:/Test#testInd2">
<rdf:type rdf:resource="file:/Test#Test1"/>
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
</rdf:Description>
<rdf:Description rdf:about="file:/Test#Test1">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/>
</rdf:Description>
<rdf:Description rdf:about="file:/Test#Test2">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/>
</rdf:Description>
<rdf:Description rdf:nodeID="A1">
<rdf:type rdf:resource="file:/Test#Test2"/>
</rdf:Description>
<rdf:Description rdf:about="file:/Test">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Ontology"/>
</rdf:Description>
</rdf:RDF>