Getting Dbpedia Results With Optional Properties
I'm building an app which shows information about entities of a given text. I'm using a sparqlwrapper library for Python to query DBpedia. I'm using the following code when I get a
Solution 1:
The entire optional block either matches or it doesn't. If you want to optionally match a few different things, you need multiple optional blocks, as in
SELECT * WHERE {
?x rdfs:label "New York"@en.
?x dbpedia-owl:abstract ?abstract.
OPTIONAL { ?x dbpedia-owl:areaTotal ?areaTotal. }
OPTIONAL { ?x dbpprop:governor ?governor. }
OPTIONAL { ?x dbpprop:birthPlace ?birthPlace. }
FILTER (LANG(?abstract) = 'en')
}
Post a Comment for "Getting Dbpedia Results With Optional Properties"