Artificial intelligence 如何使用deftemplate将结果存储在剪辑中?

Artificial intelligence 如何使用deftemplate将结果存储在剪辑中?,artificial-intelligence,clips,Artificial Intelligence,Clips,我试图构建一个模板来存储我计算的一些结果,所以我做了以下初始化: (deftemplate tempAlumne (slot nota-media-total) (slot nota-media-obligatorias) (slot nota-media-optativas) (slot nota-media-ales) ) (deffacts tempAlumneFacts (tempAlumne (nota-media-total

我试图构建一个模板来存储我计算的一些结果,所以我做了以下初始化:

(deftemplate tempAlumne
    (slot nota-media-total)
    (slot nota-media-obligatorias)
    (slot nota-media-optativas)
    (slot nota-media-ales)
)

(deffacts tempAlumneFacts
    (tempAlumne 
        (nota-media-total -1)
        (nota-media-obligatorias -1)
        (nota-media-optativas -1)
        (nota-media-ales -1)
    )
)
然后我尝试使用这个结构来存储值,但我需要它可以从许多规则中访问,所以我决定将它变成全局的。所以我试着像这样存储值:

(defrule calcula-nota-media ""
    (not calcula-nota-media ok)
    ?*tmpA* <- (tempAlumne )

    =>
    (bind ?llista_convocs (send ?*alumne* get-IConvocatoria))
    (bind ?suma 0)
    (bind ?i 0) 
    (while(< ?i (length$ ?llista_convocs)) do
        (bind ?convoc_actual (nth$ ?i ?llista_convocs))
        (bind ?suma (+ ?suma (send ?convoc_actual get-Nota)))
        (bind ?i (+ ?i 1))
    )   
    (/ )    
    (modify (?*tmpA* (nota-media-total (/ ?suma ?i))
    (assert calcula-nota-media ok)
)
(定义计算非媒体“”
(非calcula nota媒体正常)
?*tmpA*
(绑定llista_Convalcs(发送?*alumne*获取IConvocatoria))
(绑定?suma 0)
(绑定?i 0)
(而(<?i(长度$?llista_convalcs))是
(绑定车队实际(N$个车队)
(绑定suma(+suma(发送COLAC_实际获取Nota)))
(绑定i(+i 1))
)   
(/ )    
(修改(?*tmpA*(不包括介质总数(/?suma?i))
(断言calcula nota媒体正常)
)

因为我希望?*tmpA*具有初始值,然后使用modify分配每个值(这里我分配nota media total),但它会显示“[PRNTUTIL2]语法错误:检查defrule的适当语法。”,因此我不知道是什么错了,也不知道我是否走错了路。

阅读《用户指南》会很有帮助,因为它涵盖了基本语法。我已更正了您的一些错误:

(defrule calcula-nota-media ""
    (not (calcula-nota-media ok))
    ?tmpA <- (tempAlumne)
    =>
    (bind ?llista_convocs (send ?*alumne* get-IConvocatoria))
    (bind ?suma 0)
    (bind ?i 0) 
    (while(< ?i (length$ ?llista_convocs)) do
        (bind ?convoc_actual (nth$ ?i ?llista_convocs))
        (bind ?suma (+ ?suma (send ?convoc_actual get-Nota)))
        (bind ?i (+ ?i 1))
    )   
    ; (/ )  What's this for?  
    (modify ?tmpA (nota-media-total (/ ?suma ?i)))
    (assert (calcula-nota-media ok))
)
(定义计算非媒体“”
(不是(calcula nota media ok))
?tmpA
(绑定llista_Convalcs(发送?*alumne*获取IConvocatoria))
(绑定?suma 0)
(绑定?i 0)
(而(<?i(长度$?llista_convalcs))是
(绑定车队实际(N$个车队)
(绑定suma(+suma(发送COLAC_实际获取Nota)))
(绑定i(+i 1))
)   
这是干什么用的?
(修改tmpA(nota介质总量(/?suma?i)))
(断言(calcula nota media ok))
)