Reputation: 39
I have written a SPARQL query on my own ontology which gives duplication of records, for this I also used group_concat, my query is
SELECT ?Movie (str(?y) as ?Rating) (group_concat (?z;separator=",") as ?Director)
{ ?Movie :rating ?y;
:directedBy ?z
FILTER regex(str(?Movie),'Fantastic_Four') }
GROUP BY ?y ?Movie
This query gives me the desired result but the output for Director comes in following way:
http://www.semanticweb.org/administrator/ontologies/2017/2/Ontology-Schema_Movie#Josh_Trank,http://www.semanticweb.org/administrator/ontologies/2017/2/Ontology-Schema_Movie#Joshua_Trank
I wonder why this whole URI comes, how to remove this and only print Josh_Trank, Joshua_Trank in my result?
Upvotes: 0
Views: 82
Reputation: 8465
RDF resources are identified by URIs, that's why a list of URIs is concatenated. If you need some human readable name
PREFIX : <http://www.semanticweb.org/administrator/ontologies/2017/2/Ontology-Schema_Movie#>
SELECT ?Movie (str(?y) as ?Rating)
(group_concat (?director_name;separator=",") as ?Director) {
?Movie :rating ?y;
:directedBy ?z
FILTER regex(str(?Movie),'Fantastic_Four')
BIND(strafter(str(?z),str(:)) as ?director_name)
}
GROUP BY ?y ?Movie
rdfs:label
(or something similar) if exists for the human readable name of a URIUpvotes: 1