2014-10-12 30 views
0

我有一个SPARQL查询,使用sgvizlers drucalagraph可视化。我想要一个搜索容器,用户可以输入音乐艺术家。在查询中,此时用户无法输入音乐艺术家。我想要这部分:搜索容器作为sparql查询的输入

?song dbpedia-owl:writer dbpedia:Eric_Clapton。

有一个由用户输入的变量,而不是dbpedia:Eric_Clapton就像现在一样。我该怎么做呢?这是我到目前为止的代码:资源的标签作为输入查询:

<div id="ex" 
    data-sgvizler-endpoint="http://live.dbpedia.org/sparql" 
    data-sgvizler-query=" 

     SELECT ?song_label ?artist_label ?writer ?producer 
WHERE { 
     ?song dbpedia-owl:writer dbpedia:Eric_Clapton. ?song rdfs:label ?song_label . 
    OPTIONAL {{?song dbpedia-owl:artist ?artist} UNION {?song dbpedia-owl:musicalArtist ?artist.}} 
    {?song dbpedia-owl:writer ?writer. } 
    {?song dbpedia-owl:producer ?producer. } 
    {?artist rdfs:label ?artist_label .} 

    #FILTER (?writer&&?artist!=dbpedia:Eric_Clapton) 

    } limit 100" 
    data-sgvizler-chart="sgvizler.visualization.DraculaGraph" 
    // data-sgvizler-chart-options="maxnodesize: 15; minnodesize: 2" 
    style="width:100%; height:100%; border:1px solid black; display: inline-block;"> 

</div> 
+0

你问怎么办查询的SPARQL,或如何在draculagraph中实现搜索容器?如果它是前一个问题,那么不用'歌曲dbpedia-owl:作家dbpedia:Eric_Clapton'。我会添加一些东西,如'歌曲dbpedia-owl:作家?作家。 ?作家dbprop:姓名“用户在这里输入的内容”。 (或使用艺术家标签)。这种方式是用户输入“Eric Clapton”或“Clapton,Eric”,您将检索该资源。是你的问题吗? – 2014-10-14 18:21:28

+0

thnx很多为您的帮助!我点击了左边的箭头,但又一次点击了它。对不起。 – michAmir 2014-10-16 14:13:39

+0

我现在有这样的代码: – michAmir 2014-10-16 14:14:01

回答

0

问题是由使用RDFS解决

SELECT distinct ?clapton ?clapton_label ?artist ?artistlabel where { 
{ 
    {?artist dbpedia-owl:associatedBand ?clapton} 
UNION 
    {?artist dbpedia-owl:associatedMusicalArtist ?clapton} 
} 
?clapton rdfs:label '<?= ucwords($_GET['query']) ?>'@en. 
?clapton rdfs:label ?clapton_label . 
?artist rdfs:label ?artistlabel . 
} limit 100