SPARQL and number comparison in Sesame

A colleague of mine wanted to do a simple number comparison in Sesame2, and couldn’t make it out of the box. Because you may also want to query for “?blogposts nao:numericRating ?rating. FILTER (?rating > 8)”:

  • This won’t work: FILTER (?rating > 8)
  • This will: FILTER (?depth <= ‘5’^^<http://www.w3.org/2001/XMLSchema#integer&gt)
  • If you didn’t guess it already: its single hyphens, double hyphens won’t work!

A whole query is:

SELECT ?blogpost ?rating WHERE {
?blogpost nao:numericRating ?rating.
FILTER (?rating >= ‘8’^^<http://www.w3.org/2001/XMLSchema#integer&gt) .
}

Thanks and kudos to Manuel Möller
What is NAO? An ontology used on the Semantic Desktop to rate things. So, if you give stars to something in KDE 4.0, its a NAO triple…