【问题标题】:Using an integer slot in Protege in a Jess rule在 Jess 规则中使用 Protege 中的整数槽
【发布时间】:2018-04-07 16:34:19
【问题描述】:

我编写了以下 Jess 规则以在 Protege 本体中使用它。

(mapclass Cliente)
(defrule perfil-familia-numerosa

    ?cliente <- (object (is-a Cliente) 
        (nombre ?name) 
        (discapacidad? ?discapacity)
        (distrito_deseado ?desired_district)
        (n_miembros_familia ?n)
        (presupuesto_maximo ?max)
        (presupuesto_minimo ?min))
    (test (> n 4))
    =>
    (assert (perfil-cliente ?name soltero)))

当我尝试在 Jess 选项卡中输入它时,我收到一个类型错误 Jess reported an error in routine &gt; [...] java.lang.Integer cannot be cast to java.lang.String

但是,有问题的插槽是一个整数,所以我不清楚 Jess 为什么将它视为一个字符串。有什么帮助吗?

【问题讨论】:

    标签: protege jess


    【解决方案1】:

    问题出在这里:

    (test (> n 4))
    

    对绑定变量的引用保留'?',所以你必须写

    (test (> ?n 4))
    

    但是,最好将此约束添加到(n_miembros_familia ?n)

    (n_miembros_familia ?n&:(> ?n 4))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-08
      • 2018-05-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多