3

In a SPARQL query, it is possible to choose a language for each literal (and also strip the language tag):

CONSTRUCT {?x dc:title ?stripped_title.}
WHERE{ 
   ?x rdfs:label ?title .
   FILTER (langMatches(lang(?title),"en"))
   BIND (STR(?title)  AS ?stripped_title)
}

But, if the query has many different literal properties that can be very verbose. Is there a way to set a default language for all literals in a query? Or, at least, make this query less verbose?

dilvan
  • 2,109
  • 2
  • 20
  • 32
  • That's why [Wikidata label service](https://www.mediawiki.org/w/index.php?title=Wikidata_query_service/User_Manual&oldid=2687470#Label_service) exists. In many cases, `langMatches` is not needed... `FILTER (lang(?title1) = 'en' && lang(?title2) = 'en')`, but possibly this can impact performance. – Stanislav Kralin Mar 20 '18 at 13:49
  • `VALUES ?p {} VALUES ?lang {}` – UninformedUser Mar 20 '18 at 14:01
  • or `FILTER(?lang IN(...))` – UninformedUser Mar 20 '18 at 14:09
  • 1
    I don't want to get a set of literals for a set of languages. I want to get all literals in one specific language (my data has literals for Portuguese and English). Or maybe I didn't understand your suggestion (AKSW). – dilvan Mar 21 '18 at 10:26
  • You can store triples with labels in different languages in separate named graphs. – Stanislav Kralin Mar 23 '18 at 07:52

0 Answers0