Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reference a page that contains parenthesis in SPARQL

Tags:

python

sparql

I am trying to lookup information regarding someone on Dbpedia but their name contains parenthesis in this case ending with _(musician) which leads to an error.

SELECT ?birthPlace
WHERE {
  dbpedia:Tom_Johnston_(musician) dbpprop:birthPlace ?birthPlace   
}
like image 920
Phil H Avatar asked Jul 13 '15 13:07

Phil H


1 Answers

Parentheses aren't legal in prefixed names, but you can just use the full URI instead:

SELECT ?birthPlace
WHERE {
    <http://dbpedia.org/resource/Tom_Johnston_(musician)> dbpprop:birthPlace ?birthPlace   
}

It's also possible to escape them using \:

SPARQL local names also allow the non-alphanumeric characters allowed in IRIs via backslash character escapes (e.g. ns:id\=123).

SELECT ?birthPlace
WHERE {
    dbpedia:Tom_Johnston_\(musician\) dbpprop:birthPlace ?birthPlace   
}
like image 119
user205512 Avatar answered Oct 04 '22 02:10

user205512