2013-06-27 84 views
1

我想在本體中動態添加信息。我成功地與使用SPARQL將標籤和註釋標籤插入到本體中

INSERT DATA { 
GRAPH <http://www.semanticweb.org/alexandrina/ontologies/2013/3/myOntology> 
    { 
    <http://www.semanticweb.org/alexandrina/ontologies/2013/3/myOntology#Cough>    
    <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
    <http://www.semanticweb.org/alexandrina/ontologies/2013/3/myOntology#Diseases> 
    } 
} 

添加這樣的事情

<myOntology:Diseases rdf:about="&myOntology;Cough"> 
    <rdf:type rdf:resource="&myOntology;Diseases" /> 
</myOntology:Diseases> 

但現在我想添加標籤或註釋屬性。例如,要獲得

<rdfs:comment xml:lang="en">Cough</rdfs:comment> 
<rdfs:comment xml:lang="ro">Tusea</rdfs:comment> 

我試了很多查詢,但沒有成功。這樣的查詢應該是什麼?

+1

只是說明有關的例子中,RDF/XML語法' ...'已經說過'&myOntology;咳嗽rdf:輸入myOntology:疾病',所以內部的'是多餘的。 –

+0

歡迎來到Stack Overflow!我發現你已經發布了一些問題,只是想讓你知道,如果他們爲你工作,你可以[接受答案](http://meta.stackexchange.com/a/5235/225437)讓其他用戶知道答案適用於您的問題(並獎勵具有某些聲望點的答案)。在這種情況下,提供的SPARQL查詢是否適合您?如果不是,你能讓我們知道什麼沒有起作用嗎,也許它可以修復? –

回答

3

你插入查詢可以使用前綴更簡明地寫了一下,並通過使用a簡寫rdf:type

PREFIX : <http://www.semanticweb.org/alexandrina/ontologies/2013/3/myOntology#> 
INSERT DATA { 
GRAPH <http://www.semanticweb.org/alexandrina/ontologies/2013/3/myOntology> 
    { 
    :Cough a :Diseases 
    } 
} 

要添加額外的數據,你只需要更多的三元組添加到圖形模式:

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> 
PREFIX : <http://www.semanticweb.org/alexandrina/ontologies/2013/3/myOntology#> 
INSERT DATA { 
GRAPH <http://www.semanticweb.org/alexandrina/ontologies/2013/3/myOntology> 
    { 
    :Cough a :Diseases ; 
      rdfs:label "Cough"@en , "Tusea"@ro . 
    } 
} 

注意,圖形圖案

:Cough a :Diseases ; 
     rdfs:label "Cough"@en , "Tusea"@ro . 

相當於更詳細的圖案

:Cough a :Diseases . 
:Cough rdfs:label "Cough"@en . 
:Cough rdfs:label "Tusea"@ro .