【发布时间】:2015-01-21 15:24:41
【问题描述】:
如何提取在家中没有用户时关闭的所有执行器。我试图编写 Jena 规则,但无法获得正确的输出。我已经添加了我想要的结果。需要帮助编写规则。
[rule1: noValue(:users :hasLocation :home) ->
(:actuators :hasLocation :home)
(:actuators :state "OFF"^^xsd:boolean)]
[rule2: noValue(:users :hasLocation :home) ->
(?x rdf:type :actuators)
(?x :hasLocation :home)
(?x :state "OFF"^^xsd:boolean)]
{ rulex: [noValue(:subject1 :hasPropertyP2 :Object1) ->
(:subject2 :hasProperty1 :Object2)
(:subject2 :hasPropertyP3 Object3)] }
Ontology:
class:user
Individual user_1 -> user
Individual user_2 -> user
.
.
class: actuators
subclass: ac -> actuators
subclass: light -> actuators
subclass: other -> actuators
Individual central_ac -> ac
Individual room_lighting -> light
Individual tv -> other
Individual refridgration -> other
Individual heater -> other
result for rule1 [:actuators :state "OFF"^^xsd:boolean]
result for rule2 [:4e62503a:14b01762f42:-7eea :state "OFF"^^xsd:boolean]
desired result:
[central_ac :state "OFF"^^xsd:boolean]
[room_lighting :state "OFF"^^xsd:boolean]
[tv :state "OFF"^^xsd:boolean]
.
.
【问题讨论】:
-
基于 your comment 在您之前的问题中,您说 “哪些个人将 o 作为属性 p 的值?” .. 正是我想要找回的。,你可以打电话给listResourcesWithProperty(property,object)。您不需要为此制定规则。
-
在你的许多规则中使用类名作为主题对我来说没有意义。例如,您的规则 1 应该类似于
[rule1: (?actuator :hasLocation ?home) noValue(?user :hasLocation ?home) -> (?actuator :state "false"^^xsd:boolean)]。 -
规则 1 和规则 2 是相同的,我的意思是解释我的情况,当我将规则 1 用于所需的输出时,我看到的是规则 1 的结果,同样适用于规则 2。我只有一条规则。 rulex 是一个用来解释我的想法的模板。
标签: sparql rdf jena semantic-web jena-rules