2

Im trying to get the capital of the country from rdf using rdf4h

Right (rdf::TriplesGraph) <- parseURL (XmlParser Nothing Nothing) "http://live.dbpedia.org/data/Spain.rdf"

let c = query rdf (Just (UNode "http://live.dbpedia.org/resource/Spain"))  (Just (UNode "http://live.dbpedia.org/property/capital")) Nothing

but it returns empty list

I can see that it has triple with

"ns3:string" 

predicate, instead of

"http://live.dbpedia.org/property/capital"

after parsing URL,

How should I resolve this or am I missing some other method?

Edit: found this function

uniqTriplesOf :: rdf -> Triples

which does expand the namespaces, now the question is how can I query this rdf by full uris

Herokiller
  • 2,891
  • 5
  • 32
  • 50
  • What's the exact data you are are querying? - can you show us the relevant triples (just the ones that ought to match your query)? – DNA Mar 13 '15 at 08:28
  • @DNA I want to get "http://live.dbpedia.org/resource/Madrid", by "http://live.dbpedia.org/resource/Spain" and "http://live.dbpedia.org/property/capital" – Herokiller Mar 13 '15 at 08:55
  • Note that the data contains both an `ns2` prefix, mapped to `http://live.dbpedia.org/property/` and an `ns3` prefix, mapped to `http://live.dbpedia.org/ontology/` and the Spain resource has both an `ns2:capital` and an `ns3:capital` property (both pointing to Madrid) – DNA Mar 13 '15 at 11:04
  • @DNA but I know I need this http://live.dbpedia.org/property/capital one, and cannot get real uri only "ns3:string" thing – Herokiller Mar 13 '15 at 11:16

1 Answers1

1

This appears to be a shortcoming in the rdf4h API. For now, the way to write your query is:

Right (rdf::TriplesGraph) <- parseURL
           (XmlParser Nothing Nothing)
           "http://live.dbpedia.org/data/Spain.rdf"
let c = query rdf
          (Just (UNode "http://live.dbpedia.org/resource/Spain"))
          (Just (UNode "ns2:capital"))
          Nothing

I'll look to add a function to the API:

queryExpanded :: rdf -> Maybe Node -> Maybe Node -> Maybe Node -> Triples

Which would, when its implemented in the future, let you write:

let c = queryExpanded rdf
          (Just (UNode "http://live.dbpedia.org/resource/Spain"))
          (Just (UNode "http://live.dbpedia.org/property/capital"))
          Nothing
Rob Stewart
  • 1,812
  • 1
  • 12
  • 25