I need to get persons' names from DBPedia, but the problem is that not every person has the dbpprop:fullname
property, sometimes it only has the dbpprop:name
or the rdfs:label
property.
To clarify: I want to query for the name with a preference for the first property, if that doesn't exist get the second property, and if that doesn't exist get the third property, etc.
So how could I get person's name from the
dbpprop:name (person name = [dbpprop:name] if no [dbpprop:fullname])
and from
rdfs:name (person name = [rdfs:name] if no both [dbpprop:fullname] and [dbpprop:name])
You can do this using a
COALESCE
function:Result
COALESCE
takes a list of arguments as input, and outputs the first of those arguments that does not correspond to an error. Since an unbound variable corresponds to an error, this will return the full name if it exists, otherwise the name if it exists, otherwise the label if it exists.