Reputation: 11
I use http://dbpedia.org/sparql to do this request:
PREFIX res: <http://dbpedia.org/resource/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?trad
where{
res:Apple
rdfs:label ?trad
}
which returns me the following result:
How do I get the language tag (@ar, @es, @fr) in a separated column?
I've seen on w3.org something that could maybe help:
Any ideas?
Upvotes: 1
Views: 2410
Reputation: 1
To assemble "@fr", "@es", and "@ar" language tag values into one table, with separated columns, try the SPARQL UNION keyword, and FILTER with the language function on each variable:
PREFIX dbr: <http://dbpedia.org/resource/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?french ?spanish ?arabic
where{ { dbr:Apple rdfs:label ?french FILTER ( lang(?french) = "fr" ) }
UNION
{ dbr:Apple rdfs:label ?spanish FILTER ( lang(?spanish) = "es" ) }
UNION
{ dbr:Apple rdfs:label ?arabic FILTER ( lang(?arabic) = "ar" ) }}
Upvotes: 0
Reputation: 8465
SPARQL documentation contains everything about SPARQL, thus, it's always the most appropriate source to dig into.
In your case, the part about the language of an RDF term is useful.
PREFIX res: <http://dbpedia.org/resource/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?trad (lang(?trad) as ?lang) WHERE {
res:Apple rdfs:label ?trad
}
Upvotes: 7