为什么模型查询不返回查询结果? (clj-广场)
我正在使用 clj-plaza
(0.0.5-SNAPSHOT) 查询 Sesame/Jena 模型。函数 model-query
似乎没有执行查询。相反,它返回 clj-plaza 查询的内部表示。
(init-jena-framework)
(def *m* (build-model))
(with-model *m*
(model-add-triples
(model-to-triples
(document-to-model "http://www.rdfdata.org/dat/rdfdata.rdf"
:rdf))))
(def all-subjects-query
(defquery
(query-set-vars [:?subject])
(query-set-pattern (make-pattern [[:?subject ?p ?o]]))
(query-set-type :select))
;; As expected
(model-query-triples *m* all-subjects-query)
=> clojure.lang.LazySeq@2e1e8502
;; Does not execute query (?)
(model-query *m* all-subjects-query)
=> {:kind :select, :pattern [[:?object :?p :?o]], :vars [:?object]}
官方 教程 声明 model- query
返回查询中的绑定列表:
({:?object "http://randomurl.com/asdf"}
{:?object "http://asdf.com/qwer"})
I am using clj-plaza
(0.0.5-SNAPSHOT) to query a Sesame/Jena Model. The function model-query
does not appear to execute the query. It returns the internal representation of a clj-plaza
query instead.
(init-jena-framework)
(def *m* (build-model))
(with-model *m*
(model-add-triples
(model-to-triples
(document-to-model "http://www.rdfdata.org/dat/rdfdata.rdf"
:rdf))))
(def all-subjects-query
(defquery
(query-set-vars [:?subject])
(query-set-pattern (make-pattern [[:?subject ?p ?o]]))
(query-set-type :select))
;; As expected
(model-query-triples *m* all-subjects-query)
=> clojure.lang.LazySeq@2e1e8502
;; Does not execute query (?)
(model-query *m* all-subjects-query)
=> {:kind :select, :pattern [[:?object :?p :?o]], :vars [:?object]}
The official tutorial claims model-query
returns a list of bindings from the query:
({:?object "http://randomurl.com/asdf"}
{:?object "http://asdf.com/qwer"})
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个错误。
这是一个修复。在它被合并回来并在 clojars 上更新之前,请随意使用我的 fork。
解决方法是在导入相应的 Jena 或 Sesame 实现后使用
(query model query)
(而不是model-query
)。对于芝麻:
This is a bug.
Here is a fix. Until it is merged back and updated on clojars, feel free to use my fork.
A workaround would be to use
(query model query)
(instead ofmodel-query
)after importing the corresponding Jena or Sesame implementation.For Sesame: