2

我试图使用 rdf4h 从 rdf 获取该国的首都

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

但它返回空列表

我可以看到它有三倍

"ns3:string" 

谓词,而不是

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

解析网址后,

我应该如何解决这个问题或者我错过了其他方法?

编辑:找到这个功能

uniqTriplesOf :: rdf -> Triples

它确实扩展了命名空间,现在的问题是我如何通过完整的 uris 查询这个 rdf

4

1 回答 1

1

这似乎是 rdf4h API 的一个缺点。目前,编写查询的方法是:

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

我将向 API 添加一个函数:

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

这将在未来实施时,让您编写:

let c = queryExpanded rdf
          (Just (UNode "http://live.dbpedia.org/resource/Spain"))
          (Just (UNode "http://live.dbpedia.org/property/capital"))
          Nothing
于 2015-10-20T13:06:33.683 回答