【问题标题】:find relation in CLIPS expert systems在 CLIPS 专家系统中查找关系
【发布时间】:2014-05-16 17:32:32
【问题描述】:

如何使用 CLIPS 找到家谱中两个或多个家庭成员之间的关系。我试过这个规则,但它不起作用。我有一个语法错误。

是否有任何提示可以避免该错误。

(defrule Family
     (FamilyTree ?L-name ?F-name)
      =>
      (assert(FamilyTree ?L-name ?F-name(read))
      (printout t ?L-name "is parent of" ?F-name crlf)))

【问题讨论】:

  • 您应该包括确切的错误。
  • [PRNTUTIL2]语法错误:检查 deftemplate 模式的适当语法。
  • 您是否在 (assert(FamilyTree ?L-name ?F-name(read)) 之后缺少括号?
  • 不,完全没有,我的代码本身有问题
  • 需要一些额外的信息:代码应该做什么?取而代之的是什么?

标签: expert-system clips


【解决方案1】:

您的问题中似乎缺少一些关键信息。您发布的代码 sn-p 正确加载。只有当我添加 FamilyTree deftemplate 时,我才会收到您描述的错误。如果您在规则中使用 deftemplate 事实,则必须使用需要指定插槽名称的 deftemplate 事实的语法。

CLIPS> (clear)
CLIPS> 
(defrule Family
   (FamilyTree ?L-name ?F-name)
   =>
   (assert(FamilyTree ?L-name ?F-name(read))
   (printout t ?L-name "is parent of" ?F-name crlf)))
CLIPS> (clear)
CLIPS> (deftemplate FamilyTree (slot last-name) (slot first-name))
CLIPS> 
(defrule Family
   (FamilyTree ?L-name ?F-name)
   =>
   (assert(FamilyTree ?L-name ?F-name(read))
   (printout t ?L-name "is parent of" ?F-name crlf)))

[PRNTUTIL2] Syntax Error:  Check appropriate syntax for deftemplate patterns.

ERROR:
(defrule MAIN::Family
   (FamilyTree ?L-name
CLIPS> 

【讨论】:

    猜你喜欢
    • 2018-03-05
    • 1970-01-01
    • 1970-01-01
    • 2011-03-15
    • 1970-01-01
    • 2011-01-23
    • 2021-02-05
    • 2010-09-27
    • 2010-09-15
    相关资源
    最近更新 更多