Generating values for empty attributes
Asked Answered
T

1

5

I am trying to fill the empty spaces generated by the use of Optional in the SPARQL query language. Are there any ways that I can achieve this?

The use of !bound on the optional variable generates true or false, but I want to fill the cells with my own values such as "?" or "unknown".

Termite answered 1/11, 2013 at 9:5 Comment(2)
Please can you show the code you're using currently.Extrauterine
Select ?a ?b ?c Where ?a1 rdfs:type hvs:whi; rdfs:label ?a ?a2 rdfs:type hvs:whi; rdfs:label ?a Optional ?s1 rdf:type hvs:whi; rdfs:label ?b . ?m hvs:wmm ?a; hvs:into ?s1; hvs:will ?c . Filer (?c =1 ll ?c = 2 ll (!bound (?c) = 'unknown') Issue: the resultset has some ?c without values (empty cells). I want to replace these cells with 'unknown'. Sorry that i cound not follow strickly the syntax of sparql with respect to curves. I am using my phone to type. RegardsTermite
E
8

Perhaps you could use one of the following constructs...

COALESCE(?c, "unknown")

Source: http://www.w3.org/TR/sparql11-query/#func-coalesce

or

IF(bound(?c), ?c, "unknown")

Source: http://www.w3.org/TR/sparql11-query/#func-if

Extrauterine answered 1/11, 2013 at 14:25 Comment(2)
This answer by AndyS gives some more examples.Illustrative
Thanks so much. I achieved the answer through embedding your option in a subquery.Termite

© 2022 - 2024 — McMap. All rights reserved.