简体   繁体   English

“为所有人”使用 Apache Jenas 规则引擎

[英]"For all" using Apache Jenas rule engine

I'm currently working on some small examples about Apache Jena.我目前正在研究一些关于 Apache Jena 的小例子。 What I want to show is universal quantification.我想展示的是通用量化。

Let's say I have balls that each have a different color.假设我有一个球,每个球都有不同的颜色。 These balls are stored within boxes.这些球存放在盒子里。 I now want to determine whether these boxes only contain balls that have the same color of if they are mixed.我现在想确定这些盒子是否只包含与混合时颜色相同的球。

So basically something along these lines: SAME_COLOR = ∃x∀y:{y in Box a → color of y = x}所以基本上是这样的:SAME_COLOR = ∃x∀y:{y in Box a → color of y = x}

I know that this is probably not possible with Jena, and can be converted to the following: SAME_COLOR = ∃x¬∃y:{y in Box a → color of y != x}我知道这对于 Jena 来说可能是不可能的,并且可以转换为以下内容:SAME_COLOR = ∃x¬∃y:{y in Box a → color of y != x}

With "not exists" Jena's "NoValue" can be used, however, this does (at least for me) not work and I don't know how to translate above logical representations in Jena.可以使用“不存在”Jena 的“NoValue”,但是,这(至少对我而言)不起作用,我不知道如何在 Jena 中翻译上述逻辑表示。 Any thoughts on this?对此有何想法?

See the code below, which is the only way I could think of:请参阅下面的代码,这是我能想到的唯一方法:

(?box, ex:isA, ex:Box)
(?ball, ex:isIn, ?box)
(?ball, ex:hasColor, ?color)
(?ball2, ex:isIn, ?box)
(?ball2, ex:hasColor, ?color2)
NotEqual(?color, ?color2)
->
(?box, ex:hasSomeColors, "No").


(?box, ex:isA, ex:Box)
NoValue(?box, ex:hasSomeColors)
->
(?box, ex:hasSomeColors, "Yes").

A box with mixed content now has both values "Yes" and "No".具有混合内容的框现在具有值“是”和“否”。

I've ran into the same sort of problem, which is more simplified.我遇到了同样的问题,它更简单。 The question is how to get a collection of objects or count no.问题是如何获取对象集合或计数。 of objects in rule engine.规则引擎中的对象。 Given that res:subj ont:has res:obj_xxx (several objects), how to get this value in rule engine?鉴于res:subj ont:has res:obj_xxx (几个对象),如何在规则引擎中获取此值?

But I just found a Primitive called Remove(), which may inspire me a bit.但是我刚刚找到了一个名为 Remove() 的 Primitive,这可能会对我有所启发。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM