【问题标题】:Jess in Protege: multi-slot setting issueJess in Protege:多槽设置问题
【发布时间】:2016-05-21 01:35:12
【问题描述】:

根据AddingRuleWithJessTab 中给出的多槽设置示例规则AssertingHasSiblingMulti1,我创建了以下Jess 规则,用于在我的属性foundPollutionSources 上设置多槽值:

(defrule findPHPolluters
(declare (salience 553))
    (object 
        (is-a http..#PollutionSources)              
        (OBJECT ?sitepoll)          
        (http..potentialPollutant           
        $? ?b&:(eq (instance-name ?b)(instance-name http..#pH)) $?) 
        (http..#pollutionSourceName ?psName) 
        (http..#pollutionType ?psType) 
    )     
    (object 
        (is-a http..#MeasurementSite) 
        (OBJECT ?loc)
        (http..#hasSourcesOfPollution $?sitepoll_list)
    )
    (object 
            (is-a http..#ModeratePHMeasurement) 
            (OBJECT ?mob)
            (http..#observationResultLocation ?loc)
            (http..#foundPollutionSources $?existing_poll_list)
    )
=> 
    (if (not (member$ ?sitepoll $?sitepoll_list)) then 
    (printout t "pH pollution source: " ?psName " (Location: " ?psType ")" crlf)
    (slot-set ?mob http..#foundPollutionSources (create$ $?existing_poll_list ?sitepoll))
    )     
)

但是,当我运行此规则时,会出现以下异常:

Jess 在执行时报告了例程 ValueVector.set 中的错误 规则 LHS (MTELN),同时执行规则 LHS (TECT)。消息:不好 在此向量上调用 set() 时的索引 117:...

【问题讨论】:

    标签: java protege jess


    【解决方案1】:

    绑定到(部分)多槽值的变量与通常的 Jess 使用模式存在偏差。观察:

    (object 
       ...
      (http..#foundPollutionSources $?existing_poll_list))
    

    前缀 '$' 导致 foundPollutionSources 槽中的所有值都绑定到 ?existing_poll_list。通常的用法(参见 Jess 手册和链接示例)例如:

    (printout t "pollution sources " ?existing_poll_list crlf))
    

    但是您的 RHS 代码有

     (create$ $?existing_poll_list ...)
    

    注意虚假的“$” - 我会省略它并重试。

    我不知道 protege 和/或 Jess 对此有何看法,我也没有时间研究后者。

    【讨论】:

    • 我不想像你说的那样打印实例,而是想用 ?sitepoll 实例填写 slot foundPollutionSources 值。我试图删除'$'符号,错误没有出现,但再次没有达到目标
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-06
    • 1970-01-01
    相关资源
    最近更新 更多