I am having a serious trouble with the rule engine Jess. The problem that I am facing is with the Conditional Element Accumulate. I am trying to write a rule which gives me a list of words - according to some criteria - from my working memory but it shows me all the phases of the list - first an empty list then a list with one element and it goes on- which it does so by firing again and again the same rule. But I know and sure that the working memory does not change while this rule fires.
And also strangely I wrote the same rule hours ago and it was giving, as a result, only one list which has more than one elements.
Do you have any suggestions on what I am doing wrong?
Please help! Here is the code :
(defrule show-me
(declare (salience -11)
(no-loop TRUE))
?my-list <- (accumulate (bind ?list (new java.util.ArrayList)) ;initializer
(?list add ?sWord) ; action
?list ;result
(ourObject (sourceWord ?sWord) ; CE
{complementType == COMPLEMENTO-OGGETTO-PARTITIVO}))
=>
(printout t "complementType" (?my-list toString) crlf))
And this is the result that I am getting :
complementType[ un , po , di , acqua , tua ]
complementType[ un , po , acqua , tua ]
complementType[ un , acqua , tua ]
complementType[ acqua , tua ]
complementType[ acqua ]
complementType[]
And I need only this :
complementType[ un , po , di , acqua , tua ]
p.s. Sorry for the code appearance but it did not permit me to paste it as it is.