-1

I want to delete all words from sentense that are shorter that 4 letters. Print result sentence and count of deleted words. Print result on the screen and in the text file.

CLIPS Expert System. There are few guides all over the internet

IchigoWalker
  • 145
  • 8

1 Answers1

1

Here's a start:

CLIPS> 
(deftemplate sentence
   (multislot text)
   (slot deleted_count (default 0)))
CLIPS> 
(defrule delete
   ?f <- (sentence (text $?b ?word&:(< (str-length ?word) 4) $?e)
                   (deleted_count ?count))
   =>
   (modify ?f (text ?b ?e) (deleted_count (+ 1 ?count))))
CLIPS> (assert (sentence (text the quick brown fox jumped over the lazy dogs)))
<Fact-1>
CLIPS> (run)
CLIPS> (facts)
f-0     (initial-fact)
f-4     (sentence (text quick brown jumped over lazy dogs) (deleted_count 3))
For a total of 2 facts.
CLIPS> 

When asking questions on Stack Overflow you should make at a least a token effort to demonstrate that you've read the available documentation and made an effort to solve the problem.

Gary Riley
  • 10,130
  • 2
  • 19
  • 34
  • thx! i was trying to make something like this `(defmethod Ichi () (bind ?input (explode$ "hammer dril saw screw")) (bind ?result "") (loop-for-count (?i 1 4) do (bind ?word (nth$ ?i ?input)) (if (< (length$ ?word) 4) then (str-cat ?word ?result) ) (printout t ?word crlf) ) ?result )` – IchigoWalker Apr 15 '16 at 10:34