2015-11-03 34 views
1

我想提取關於歐洲議會一個特定的議題,這是通過SPARQL接口這裏訪問的講話重複行http://linkedpolitics.ops.few.vu.nl/home當製作SPARQL查詢

通過下面的查詢

SELECT ?speaker ?given ?surname ?acronym ?text ?partyLabel ?type 
WHERE { 
    <http://purl.org/linkedpolitics/eu/plenary/2010-12-16_AgendaItem_4> dcterms:hasPart ?speech. 
    ?speech lpv:speaker ?speaker. 
    ?speaker foaf:givenName ?given. 
    ?speaker foaf:familyName ?surname. 
    ?speaker lpv:countryOfRepresentation ?country. 
    ?country lpv:acronym ?acronym. 
    ?speech lpv:translatedText ?text. 
    ?speaker lpv:politicalFunction ?func. 
    ?func lpv:institution ?institution. 
    ?institution rdfs:label ?partyLabel. 
    ?institution rdf:type ?type. 
    FILTER(langMatches(lang(?text), "en")) 
} 

我得到我想要的信息,但所有的行重複數次。當我嘗試通過它看起來的政治功能訪問派對標籤時,會發生這種情況。我如何獲得唯一的行,以及重複出現在第一位的原因是什麼?

+0

我有一個類似的問題,我發現了一個解決方案:HTTP://計算器的.com /問題/ 28988702 /不同只對單值與 - SPARQL – drstein

回答

4

您正在使用大量的變量,而您並未選擇所有變量。這意味着你回來的行的差異可能在你實際沒有選擇的變量中。例如,如果你有數據:

:a :hasChild :b . 
:a :hasChild :c . 

,你運行查詢:

select ?parent where { 
    ?parent :hasChild ?child . 
} 

你會得到的結果是兩行:

?parent 
------- 
:a 
:a 

因爲有兩個綁定關係提供解決方案:一個孩子是:a,一個孩子在哪裏?b。

爲避免這種情況,您可以使用選擇不同的,這會刪除「重複」結果行。只要做到:???????

選擇DISTINCT揚聲器給出姓的首字母縮寫文本partyLabel鍵入