- From: Paul Tyson <phtyson@sbcglobal.net>
- Date: Thu, 22 Mar 2018 09:53:56 -0500
- To: Mikael Pesonen <mikael.pesonen@lingsoft.fi>
- Cc: semantic-web@w3.org
Something like this might work (untested): SELECT (min(?s) as ?preferred_s) ?s_type FROM <http://some_graph/> WHERE { ?s a ?s_type . ?s <http://schema.org/name> ?s_label_g BIND (if (lang(?s_label_g) = "en" ,1 ,if(lang(?s_label_g) = "",2,3)) AS ?priority) } group by ?s ?s_type order by ?priority asc Regards, --Paul On Thu, 2018-03-22 at 14:45 +0200, Mikael Pesonen wrote: > Hi, > > I'm having trouble contructing a basic query which selects a string so > that it prefers one language, over others but always tries to return > something. > > So I have names > > :item schema:name "name"@en > :item schema:name "nimi"@fi > :item schema:name "namn" > > I need query that returns the English name ("name"@en) , but if not > found the name without language ("namn"), and as last resort name in > Finnish ("nimi"@fi) > > This query returns one random name: > > SELECT > ?s > (SAMPLE(?s_label_g) as ?s_label) > ?s_type > FROM <http://some_graph/> > WHERE > { > ?s a ?s_type . > ?s <http://schema.org/name> ?s_label_g > } > GROUP BY ?s ?s_type > > > Anyone can help? >
Received on Thursday, 22 March 2018 14:54:31 UTC