Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sparql exact match regex

Tags:

regex

sparql

I'am using the following sparql query to extract from dbpedia the pages which match a specific infobox:

PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX dbpedia: <http://dbpedia.org/property/>
PREFIX res:<http://dbpedia.org/resource/>
SELECT DISTINCT *
WHERE {
?page dbpedia:wikiPageUsesTemplate ?template .
?page rdfs:label ?label .
FILTER (regex(?template, 'Infobox_artist')) .
FILTER (lang(?label) = 'en')
}
LIMIT 100

In this line of the query :

FILTER (regex(?template, 'Infobox_artist')) .

I get all the infoboxes that start with artist as artist_discography and other which I don't need. My question is: how can I get by a regex only the infoboxes that matche exactly "infobox_artist" ?

like image 613
Funmatica Avatar asked Jan 15 '23 14:01

Funmatica


1 Answers

As it is a regex you should be able to restrict the search as follows:

FILTER (regex(?template, '^Infobox_artist$')) .
  • ^ is the beginning of a string
  • $ is the end of a string

in a regex.

NB: I've not used sparql, so this may well not work.

like image 59
beny23 Avatar answered Jan 24 '23 14:01

beny23