从sentense删除所有短于4个字母的单词

时间:2016-04-14 13:15:32

标签: clips expert-system

我想删除所有短于4个字母的单词。打印结果语句和删除的单词计数。在屏幕和文本文件中打印结果。

CLIPS专家系统。互联网上很少有指南

1 个答案:

答案 0 :(得分:1)

这是一个开始:

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> 

在Stack Overflow上提问时,您至少应该努力证明您已经阅读了可用的文档并努力解决问题。