[OK?] Re: SPARQL: language tag issues

On Tue, Nov 22, 2005 at 04:19:20PM +0100, Bjoern Hoehrmann wrote:
> 
> * Eric Prud'hommeaux wrote:
> >however, consistency is always nice. I'll propose
> >"In SPARQL, a language-range of "*" matches any language-tag string
> >and matches """ (maybe "the empty string"?)
> >to the DAWG.
> 
> I think I'm happy either way, the current behavior makes some sense if
> you care about only those things that have language information (though
> language tags like "und" might complicate that) while the above would
> make sense if you don't care about the language at all but hardcode the
> langmatches() for simplicity (say, the query is composed through a UI
> where some 'any language' select box entry translates to '*'). It would
> be good to give an example for both use cases in the document.

Good advice: added example to editor's draft:
[[


@prefix dc:       <http://purl.org/dc/elements/1.1/> .

_:a  dc:title         "That Seventies Show"@en .
_:a  dc:title         "Cette Série des Années Soixante-dix"@fr .
_:a  dc:title         "Cette Série des Années Septante"@fr-BE .
_:b  dc:title         "Il Buono, il Bruto, il Cattivo" .

This query uses langMatches and lang (described in section 11.2.3.8) to find the French titles for the show known in English as "That Seventies Show":

PREFIX dc: <http://purl.org/dc/elements/1.1/>
SELECT ?title
 WHERE { ?x dc:title  "That Seventies Show"@en ;
            dc:title  ?title .
         FILTER langMatches( lang(?title), "FR" ) }

Query result:
title
"Cette Série des Années Soixante-dix"@fr
"Cette Série des Années Septante"@fr-BE

The idiom langMatches( lang( ?v ), "*" ) will not match literals without a language tag as lang( ?v ) will return an empty string, so

PREFIX dc: <http://purl.org/dc/elements/1.1/>
SELECT ?title
 WHERE { ?x dc:title  ?title .
         FILTER langMatches( lang(?title), * ) }

will report all of the titles with a language tag:
title
"That Seventies Show"@en
"Cette Série des Années Soixante-dix"@fr
"Cette Série des Années Septante"@fr-BE
]]

[CLOSED] ?
-- 
-Eric

office: +81.466.49.1170 W3C, Keio Research Institute at SFC,
                        Shonan Fujisawa Campus, Keio University,
                        5322 Endo, Fujisawa, Kanagawa 252-8520
                        JAPAN
        +1.617.258.5741 NE43-344, MIT, Cambridge, MA 02144 USA
cell:   +81.90.6533.3882

(eric@w3.org)
Feel free to forward this message to any list for any purpose other than
email address distribution.

Received on Monday, 12 December 2005 16:15:51 UTC