Hi!

I'm trying to build localization into a DBpedia application (which uses the
Virtuoso Database), but I've run into some problems.

To return multilingual results (using a given language or, if it isn't
available, falling back to an available language),
I'm using the following sort of SPARQL query (at dbpedia.org/snorql ):

SELECT * WHERE {
  {
    SELECT DISTINCT * WHERE {
      {<http://dbpedia.org/resource/Microsoft> dbpedia2:abstract ?text.}
      UNION
      {<http://dbpedia.org/resource/Microsoft> dbpedia2:abstract ?text.
FILTER langMatches( lang(?text), "FR" )}
    }
    LIMIT 1
  }
  #UNION
  #{
    #SELECT DISTINCT * WHERE {
      #{<http://dbpedia.org/resource/Google> dbpedia2:abstract ?text.}
      #UNION
      #{<http://dbpedia.org/resource/Google> dbpedia2:abstract ?text. FILTER
langMatches( lang(?text), "FR" )}
    #}
    #LIMIT 1
  #}
}

This works as long as only the first half is active. With the second half
also uncommented, it returns "S0022 Error SQ200: No column s-13-2.text."


The problems I have are:

   - How would I combine the results of two or more subqueries, and...
   - What are the rules for the order or precedence of results from unions?


To be more specific with the second question:
if the first subquery of the example code above has its union statements
reversed, it will return an English result instead of a French one.

Example:

SELECT DISTINCT * WHERE {
  {<http://dbpedia.org/resource/Microsoft> dbpedia2:abstract ?text. FILTER
langMatches( lang(?text), "FR" )}
  UNION
  {<http://dbpedia.org/resource/Microsoft> dbpedia2:abstract ?text.}
}
LIMIT 1

Does anyone know of answers to these problems?

Thank you,
Stephen Hatton

Reply via email to