regex - SPARQL regular expression not match -


i want movies without "the lord of rings" string in title. tried @ linked movie database sparql endpoint, doesn't work. wrong?

prefix m: <http://data.linkedmdb.org/resource/movie/> select distinct *  {    ?film dc:title ?titulo_pelicula.    filter not exists {        filter (regex(?titulo_pelicula, "the lord of rings","i")) .     } } 

first, should clarify mean “doesn't work.” @ first, i'd assumed meant doesn't return results, when ran @ the endpoint, realized you're getting clear error message what's wrong:

parse error:  prefix owl: <http://www.w3.org/2002/07/owl#> prefix xsd: <http://www.w3.org/2001/xmlschema#> prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> prefix foaf: <http://xmlns.com/foaf/0.1/> prefix oddlinker: <http://data.linkedmdb.org/resource/oddlinker/> prefix map: <file:/c:/d2r-server-0.4/mapping.n3#> prefix db: <http://data.linkedmdb.org/resource/> prefix dbpedia: <http://dbpedia.org/property/> prefix skos: <http://www.w3.org/2004/02/skos/core#> prefix dc: <http://purl.org/dc/terms/> prefix movie: <http://data.linkedmdb.org/resource/movie/> prefix m: <http://data.linkedmdb.org/resource/movie/> select distinct *  {    ?film dc:title ?titulo_pelicula.    filter not exists {        filter (regex(?titulo_pelicula, "the lord of rings","i")) .     } }  lexical error @ line 16, column 14.  encountered: " " (32), after : "not" 

you've got parse error when not. endpoint based on original sparql query language rdf rather sparql 1.1 query language. original sparql doesn't have not exists.

this easy fix though. first, recognize filter takes expression , keeps results expression evaluates true. filter expression regex(?titulo_pelicula, "the lord of rings","i") returns true when regular expression matches title, , you're looking cases returns false, need negate !. (the ! operator same xpath function not. mappings defined in section 11.3 operator mapping of sparql recommendation.) need query this:

prefix m: <http://data.linkedmdb.org/resource/movie/> select distinct *  {    ?film dc:title ?titulo_pelicula.    filter (!regex(?titulo_pelicula, "the lord of rings","i")) .  } 

sparql results


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -