Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sparql pattern matching

I'm currently learning some sparql and I'm practicing on the following website with some statements:

http://data.semanticweb.org/snorql

However, I'm trying to execute the following statement:

SELECT DISTINCT ?author WHERE { ?paper swrc:author ?author FILTER(regex(?paper, "2006")) . } .

It says that there are no results. When I run the following query (without the filter):

SELECT DISTINCT ?paper WHERE { ?paper swrc:author ?author . }

I see that there are some papers with 2006 in it's string. I'm wondering why the first query is not returning these entries where there is 2006 in the ?paper string.

Could anyone help me with this?

like image 699
Devos50 Avatar asked Oct 24 '12 17:10

Devos50


People also ask

What is SPARQL good for?

SPARQL, short for “SPARQL Protocol and RDF Query Language”, enables users to query information from databases or any data source that can be mapped to RDF. The SPARQL standard is designed and endorsed by the W3C and helps users and developers focus on what they would like to know instead of how a database is organized.

Is SPARQL the same as SQL?

Both of these languages give the user access to create, combine, and consume structured data. SQL does this by accessing tables in relational databases, and SPARQL does this by accessing a web of Linked Data.

What is SPARQL prefix?

"PREFIX", however (without the "@"), is the SPARQL instruction for a declaration of a namespace prefix. It allows you to write prefixed names in queries instead of having to use full URIs everywhere. So it's a syntax convenience mechanism for shorter, easier to read (and write) queries.


1 Answers

The RDF terms returned for ?paper are all URIs. The REGEX filter function doesn't work on URIs; it only works on strings. You can turn a URI into a string using the STR(…) function. This will work:

FILTER(regex(STR(?paper), "2006"))
like image 67
cygri Avatar answered Sep 17 '22 18:09

cygri