2017-10-15 12 views
0

私はオントロジーを作成しました。その中にいくつかのデータプロパティを更新したいと思います。私はenter link description hereでSPARQL更新を読んで、私はSPARQL更新(挿入/更新)を使用して、Pellet推論に基づいてRDFトリプルを更新できることを発見しました。しかし、私はそれがデータプロパティのために有用であることは疑いがあります。UPdateデータプロパティSPARQL DELETEおよびINSERTに基づく値

たとえば、私はdatapropery has-age "has"とhas-age-category = "child"を持つpersonクラスを持っています 私はこのSPARQLクエリを作成しますが、結果はありません。

"人のNNを削除します?持っカテゴリ - 年齢 '子' \ n" は "人のNNを挿入します? '大人' - カテゴリ - 年齢を持っている\ n" は "WHERE {\ n" は 「人? \ n " "?人:nn:has-age?年齢:\ n " "?人nn:has-category-age?カテゴリー。\ n " " FILTER((has-category -age = 'child')& &(?has-age = '30 '))\ n " "} "; どうもありがとう

私のオントロジーは以下のとおりです。

<?xml version="1.0"?> 

<!-- 
/////////////////////////////////////////////////////////////////////////////////////// 
// 
// Object Properties 
// 
/////////////////////////////////////////////////////////////////////////////////////// 
--> 




<!-- http://www.semanticweb.org/hp/ontologies/2017/9/untitled-ontology-563#has-class --> 

<owl:ObjectProperty rdf:about="http://www.semanticweb.org/hp/ontologies/2017/9/untitled-ontology-563#has-class"> 
    <rdfs:domain rdf:resource="http://www.semanticweb.org/hp/ontologies/2017/9/untitled-ontology-563#Person"/> 
    <rdfs:range rdf:resource="http://www.semanticweb.org/hp/ontologies/2017/9/untitled-ontology-563#Classroom"/> 
</owl:ObjectProperty> 



<!-- http://www.semanticweb.org/hp/ontologies/2017/9/untitled-ontology-563#has-time --> 

<owl:ObjectProperty rdf:about="http://www.semanticweb.org/hp/ontologies/2017/9/untitled-ontology-563#has-time"> 
    <rdfs:domain rdf:resource="http://www.semanticweb.org/hp/ontologies/2017/9/untitled-ontology-563#Courses"/> 
    <rdfs:range rdf:resource="http://www.semanticweb.org/hp/ontologies/2017/9/untitled-ontology-563#Time"/> 
</owl:ObjectProperty> 



<!-- 
/////////////////////////////////////////////////////////////////////////////////////// 
// 
// Data properties 
// 
/////////////////////////////////////////////////////////////////////////////////////// 
--> 




<!-- http://www.semanticweb.org/hp/ontologies/2017/9/untitled-ontology-563#has-age --> 

<owl:DatatypeProperty rdf:about="http://www.semanticweb.org/hp/ontologies/2017/9/untitled-ontology-563#has-age"> 
    <rdfs:domain rdf:resource="http://www.semanticweb.org/hp/ontologies/2017/9/untitled-ontology-563#Person"/> 
    <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#integer"/> 
</owl:DatatypeProperty> 



<!-- http://www.semanticweb.org/hp/ontologies/2017/9/untitled-ontology-563#has-category-age --> 

<owl:DatatypeProperty rdf:about="http://www.semanticweb.org/hp/ontologies/2017/9/untitled-ontology-563#has-category-age"> 
    <rdfs:domain rdf:resource="http://www.semanticweb.org/hp/ontologies/2017/9/untitled-ontology-563#Person"/> 
    <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#string"/> 
</owl:DatatypeProperty> 



<!-- 
/////////////////////////////////////////////////////////////////////////////////////// 
// 
// Classes 
// 
/////////////////////////////////////////////////////////////////////////////////////// 
--> 




<!-- http://www.semanticweb.org/hp/ontologies/2017/9/untitled-ontology-563#Classroom --> 

<owl:Class rdf:about="http://www.semanticweb.org/hp/ontologies/2017/9/untitled-ontology-563#Classroom"/> 



<!-- http://www.semanticweb.org/hp/ontologies/2017/9/untitled-ontology-563#Courses --> 

<owl:Class rdf:about="http://www.semanticweb.org/hp/ontologies/2017/9/untitled-ontology-563#Courses"/> 



<!-- http://www.semanticweb.org/hp/ontologies/2017/9/untitled-ontology-563#Person --> 

<owl:Class rdf:about="http://www.semanticweb.org/hp/ontologies/2017/9/untitled-ontology-563#Person"/> 



<!-- http://www.semanticweb.org/hp/ontologies/2017/9/untitled-ontology-563#Time --> 

<owl:Class rdf:about="http://www.semanticweb.org/hp/ontologies/2017/9/untitled-ontology-563#Time"/> 



<!-- 
/////////////////////////////////////////////////////////////////////////////////////// 
// 
// Individuals 
// 
/////////////////////////////////////////////////////////////////////////////////////// 
--> 




<!-- http://www.semanticweb.org/hp/ontologies/2017/9/untitled-ontology-563#Jihed --> 

<owl:NamedIndividual rdf:about="http://www.semanticweb.org/hp/ontologies/2017/9/untitled-ontology-563#Jihed"> 
    <rdf:type rdf:resource="http://www.semanticweb.org/hp/ontologies/2017/9/untitled-ontology-563#Person"/> 
    <has-age rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">30</has-age> 
    <has-category-age rdf:datatype="http://www.w3.org/2001/XMLSchema#string">child</has-category-age> 
</owl:NamedIndividual> 



<!-- http://www.semanticweb.org/hp/ontologies/2017/9/untitled-ontology-563#Joseph --> 

<owl:NamedIndividual rdf:about="http://www.semanticweb.org/hp/ontologies/2017/9/untitled-ontology-563#Joseph"> 
    <rdf:type rdf:resource="http://www.semanticweb.org/hp/ontologies/2017/9/untitled-ontology-563#Person"/> 
    <has-age rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">10</has-age> 
    <has-category-age rdf:datatype="http://www.w3.org/2001/XMLSchema#string">child</has-category-age> 
</owl:NamedIndividual> 



<!-- http://www.semanticweb.org/hp/ontologies/2017/9/untitled-ontology-563#Ralph --> 

<owl:NamedIndividual rdf:about="http://www.semanticweb.org/hp/ontologies/2017/9/untitled-ontology-563#Ralph"> 
    <rdf:type rdf:resource="http://www.semanticweb.org/hp/ontologies/2017/9/untitled-ontology-563#Person"/> 
    <has-age rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">25</has-age> 
    <has-category-age rdf:datatype="http://www.w3.org/2001/XMLSchema#string">adult</has-category-age> 
</owl:NamedIndividual> 

答えて

2
  1. あなたの質問のフォーマットは常に質問を読み取るために、他のことができます。
  2. どのトリプルストア/ SPARQLエンジンを使用していますか?
  3. データが表示されない場合、WHEREの部分が正しく、一部のデータと一致するかどうかを確認するにはどうすればよいですか?
  4. SPARQL更新クエリのデバッグは、最初にWHERE部分が結果と一致するかどうかを確認することで可能です。これは実際にSELECTクエリを使用して行うことができます。あなたのSPARQLクエリから

私はWHERE一部に明らかなエラーを見ることができます:

WHERE { 
?person rdf:type nn:person . 
?person nn:has-age ?ag . 
?person nn:has-category-age ?categry . 
FILTER ((has-category-age='child') && (?has-age='30')) 
} 
  1. トリプルパターン?person nn:has-category-age ?categry .とFILTERは(has-category-age='child')です。どうして?再度述語を使用しないで、変数値に基づいてフィルタリングする必要があります。
  2. トリプルパターン?person nn:has-age ?ag .およびFILTERは(?has-age='30')です。以前と同じ問題は...さらに、年齢のデータ型がxsd:integerの場合は、'30'を使用できません。これは、引用符で囲むと文字列になるためです。いずれかを使用30または"30"^^xsd:integer
  3. 次回は変数名を確認してください。そこに誤字があるのは恐ろしいことです。 ?ag - >?age?categry - >WHERE?category

固定部(私は年齢が整数値であると仮定しています):

WHERE { 
    ?person rdf:type nn:person . 
    ?person nn:has-age ?age . 
    ?person nn:has-category-age ?category . 
    FILTER ((?category='child') && (?age=30)) 
} 
関連する問題