W3C home > Mailing lists > Public > semantic-web@w3.org > March 2018

Help with simple SPARQL query getting strings of selected languages

From: Mikael Pesonen <mikael.pesonen@lingsoft.fi>
Date: Thu, 22 Mar 2018 14:45:37 +0200
To: semantic-web@w3.org
Message-ID: <b2b0f345-18c5-590b-1f07-575337a4714b@lingsoft.fi>

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?

-- 
Lingsoft - 30 years of Leading Language Management

www.lingsoft.fi

Speech Applications - Language Management - Translation - Reader's and Writer's Tools - Text Tools - E-books and M-books

Mikael Pesonen
System Engineer

e-mail: mikael.pesonen@lingsoft.fi
Tel. +358 2 279 3300

Time zone: GMT+2

Helsinki Office
Eteläranta 10
FI-00130 Helsinki
FINLAND

Turku Office
Kauppiaskatu 5 A
FI-20100 Turku
FINLAND
Received on Thursday, 22 March 2018 13:34:38 UTC

This archive was generated by hypermail 2.3.1 : Thursday, 22 March 2018 13:34:48 UTC