You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Osma Suominen <os...@aalto.fi> on 2013/06/14 14:02:02 UTC

language tags given as VALUES don't work?

Hi!

I'm using a recent build of Fuseki - version 0.2.7-SNAPSHOT 
(Build date: 20130508-1013).

When I execute the following query against a SKOS vocabulary:

--cut--
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
SELECT ?lang (COUNT(?label) as ?count)
WHERE {
   ?conc a skos:Concept .
   ?conc skos:prefLabel ?label .
   FILTER (langMatches(lang(?label), ?lang))
}
GROUP BY ?lang
VALUES ?lang { 'fi' 'sv' 'en' }
--cut--

I get three rows as result, as expected (one for each language tag value), 
but ?count is always zero even though the vocabulary does contain 
skos:prefLabel values with those language tags. If I change the FILTER to 
e.g. "FILTER (langMatches(lang(?label), 'fi'))" I do get actual counts. So 
it seems that somehow the FILTER expression doesn't want to use the 
language tag from the VALUES statement.

I'm pretty sure this query worked in an earlier build of Fuseki but I 
don't have it easily available anymore. Am I doing something wrong here or 
is this a bug?

Thanks and best regards,
Osma

-- 
Osma Suominen | Osma.Suominen@aalto.fi | +358 40 5255 882
Aalto University, Department of Media Technology, Semantic Computing Research Group
Room 2541, Otaniementie 17, Espoo, Finland; P.O. Box 15500, FI-00076 Aalto, Finland

Re: language tags given as VALUES don't work?

Posted by Rob Vesse <rv...@yarcdata.com>.
When reporting a possible bug please provide a minimal reproducible test
case, this includes data!  A trivial subset of data that demonstrates the
issue is usually sufficient.

I believe that your query does not work because ?lang is not actually in
scope when the FILTER is evaluated so the FILTER eliminates everything.
Then the GROUP BY evaluates over empty results giving a single row with a
?count of 0 which is then joined with the VALUES clause giving three rows
each with a ?count of 0


If you rewrite your query like so I suspect you may get the results you
want:

PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
SELECT ?lang (COUNT(?label) as ?count)
WHERE {
  ?conc a skos:Concept .
  ?conc skos:prefLabel ?label .
  VALUES ?lang { 'fi' 'sv' 'en' }

  FILTER (langMatches(lang(?label), ?lang))
}
GROUP BY ?lang

This seems to get the correct answer for me with some fake test data I
generated, as I said at the top please provide test data when asking such
a question.  The data is often just as important (if not more) as the
query in debugging an issue!

Remember that SPARQL evaluation semantics are bottom up evaluation so the
innermost portion of the query is evaluated first and modifiers like GROUP
BY and VALUES get evaluated later.

Also note that Fuseki 0.2.7 is now a stable release as part of Jena 2.10.1
which came out a few weeks back, I would upgrade to the stable release if
you are able or if you prefer to live on the bleeding edge you can now get
0.2.8-SNAPSHOT

Rob



On 6/14/13 5:02 AM, "Osma Suominen" <os...@aalto.fi> wrote:

>Hi!
>
>I'm using a recent build of Fuseki - version 0.2.7-SNAPSHOT
>(Build date: 20130508-1013).
>
>When I execute the following query against a SKOS vocabulary:
>
>--cut--
>PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
>SELECT ?lang (COUNT(?label) as ?count)
>WHERE {
>   ?conc a skos:Concept .
>   ?conc skos:prefLabel ?label .
>   FILTER (langMatches(lang(?label), ?lang))
>}
>GROUP BY ?lang
>VALUES ?lang { 'fi' 'sv' 'en' }
>--cut--
>
>I get three rows as result, as expected (one for each language tag
>value), 
>but ?count is always zero even though the vocabulary does contain
>skos:prefLabel values with those language tags. If I change the FILTER to
>e.g. "FILTER (langMatches(lang(?label), 'fi'))" I do get actual counts.
>So 
>it seems that somehow the FILTER expression doesn't want to use the
>language tag from the VALUES statement.
>
>I'm pretty sure this query worked in an earlier build of Fuseki but I
>don't have it easily available anymore. Am I doing something wrong here
>or 
>is this a bug?
>
>Thanks and best regards,
>Osma
>
>-- 
>Osma Suominen | Osma.Suominen@aalto.fi | +358 40 5255 882
>Aalto University, Department of Media Technology, Semantic Computing
>Research Group
>Room 2541, Otaniementie 17, Espoo, Finland; P.O. Box 15500, FI-00076
>Aalto, Finland