AllegroGraph 检查现有三元组
我正在使用 AllegroGraph 4。我有一个三元组存储,并且只有在新的三元组尚不存在时我才会尝试添加它们。
这是我的 Prolog 查询:
(select (?news) (alfas ?news) (a-- ?news !tst:has-annotation !tst:Test)))
其中 alfas 检查条件(工作正常),并且 a--
的定义如下:
(<-- (a-- ?s ?p ?o)
;; Fails unless all parts ground.
(lisp (not (triple-exists-p ?s ?p ?o)))
(lisp (add-triple ?s ?p ?o)))
我也尝试过这样定义:
(<-- (a-- ?s ?p ?o)
;; Fails unless all parts ground.
(lisp (not (get-triple :s ?s :p ?p :o ?o)))
(lisp (add-triple ?s ?p ?o)))
但无论如何都添加了三元组,没有不管它是否已经存在。为什么?
I am using AllegroGraph 4. I have a triple store, and I am trying to add new triples only if they don't already exist.
Here is my Prolog query:
(select (?news) (alfas ?news) (a-- ?news !tst:has-annotation !tst:Test)))
where alfas checks for a condition(it works fine) and a--
is defined like this:
(<-- (a-- ?s ?p ?o)
;; Fails unless all parts ground.
(lisp (not (triple-exists-p ?s ?p ?o)))
(lisp (add-triple ?s ?p ?o)))
I have also tried defining it like this:
(<-- (a-- ?s ?p ?o)
;; Fails unless all parts ground.
(lisp (not (get-triple :s ?s :p ?p :o ?o)))
(lisp (add-triple ?s ?p ?o)))
But the triple is added anyway, no matter if it already exists or not. Why?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的第二次尝试更正确,但您应该使用
lispp
而不是lisp
来检查三元组是否已存在:您已经看到了此代码,因为您评论了 此处。但您一定没有注意到
lispp
函子,或者理解它作为谓词运行 - 如 文档。Your second attempt is more correct, but you should use
lispp
instead oflisp
to check if the triple already exists:You've seen this code already, because you commented here. But you must not have noticed the
lispp
functor, or understood that it runs as a predicate - as described in the documentation.