0

我想使用 Jess 在家庭本体中找到 Bob 孩子。以下规则应该这样做:

(defrule FindBobChildren
    (object (is-a https://wiki.csc.calpoly.edu/OntologyTutorial/family_example.owl#Person) 
            (OBJECT ?oi)
            (https://wiki.csc.calpoly.edu/OntologyTutorial/family_example.owl#hasParent 
            ?b&:(eq (instance-name ?b) (instance-name https://wiki.csc.calpoly.edu/OntologyTutorial/family_example.owl#Bob)))
    )
=>
    (printout t "Bob children:" (instance-name ?oi) crlf)   
)

但是,不幸的是,它只打印出只有 Bob 作为他/她的父母的孩子。例如,如果一个人有 Bob 和 Mary 作为他/她的父母,那么它不会被规则匹配。

4

1 回答 1

0

不知道#Person 的模板是如何定义的,这很困难,但从你描述的行为我推断#hasParent 是一个多槽。因此,使用这个:

(defrule FindBobChildren
    (object (is-a #Person) 
        (OBJECT ?oi)
        (#hasParent $? ?b&:(eq (instance-name ?b)(instance-name #Bob)) $?
        )
    )
=>
    (printout t "Bob children:" (instance-name ?oi) crlf)   
)
于 2015-05-13T06:08:16.330 回答