0

I have data like this:

<http://wikidata.dbpedia.org/resource/Q1000019>  <http://purl.org/voc/vrank#hasRank>
                                 [<http://purl.org/voc/vrank#rankValue> "0.15"^^xsd:float] .
<http://wikidata.dbpedia.org/resource/Q100004>   <http://purl.org/voc/vrank#hasRank>
                                 [<http://purl.org/voc/vrank#rankValue> "0.15"^^xsd:float] .
<http://wikidata.dbpedia.org/resource/Q1000047>  <http://purl.org/voc/vrank#hasRank>
                                 [<http://purl.org/voc/vrank#rankValue> "0.15"^^xsd:float] .

And I am trying a query like this:

SELECT ?c WHERE {?s <http://purl.org/voc/vrank#hasRank> ?c}

This just returns a blank node. How do get the value 0.15 which is between quotes here?

Stanislav Kralin
  • 11,070
  • 4
  • 35
  • 58
Scaraffe
  • 5,041
  • 5
  • 21
  • 20
  • It returns a blank node because the value of the property `hasRank` is a blank node. You have to resolve the blank node, i.e. in your case get the value of `rankValue`. This can be seen as a chain, i.e. `?s :hasRank ?rank . ?rank :rankValue ?value` – UninformedUser Nov 28 '16 at 21:46
  • Using property paths: `?s vrank:hasRank/vrank:rankValue ?v`. Source: http://people.aifb.kit.edu/ath/ – Stanislav Kralin Apr 22 '18 at 12:20

2 Answers2

1

You can just lift the pattern you can see in the data (reformatted a little):

SELECT ?c 
WHERE 
{ 
    ?s <http://purl.org/voc/vrank#hasRank> [ 
        <http://purl.org/voc/vrank#rankValue> ?c 
    ]
}

To explain, [ ... content ... ] is a convenience in turtle and sparql to introduce a bnode (typically in an object position) and add some properties of that bnode.

user205512
  • 8,798
  • 29
  • 28
1
DESCRIBE ?c
where {?s <http://wikidata.dbpedia.org/resource/Q1000047> <http://purl.org/voc/vrank#hasRank> ?c}

This will give you all info about your BN (?c)

Alper t. Turker
  • 34,230
  • 9
  • 83
  • 115