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’^^<
  • 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’^^< .

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…