删除句子中所有短于 4 个字母的单词
Delete all words from sentense that are shorter that 4 letters
我想从句子中删除所有短于 4 个字母的单词。打印结果语句和删除单词的计数。在屏幕和文本文件中打印结果。
CLIPS 专家系统。全网攻略少
这是一个开始:
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 上提问时,您至少应该做出象征性的努力来证明您已经阅读了可用的文档并努力解决了问题。
我想从句子中删除所有短于 4 个字母的单词。打印结果语句和删除单词的计数。在屏幕和文本文件中打印结果。
CLIPS 专家系统。全网攻略少
这是一个开始:
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 上提问时,您至少应该做出象征性的努力来证明您已经阅读了可用的文档并努力解决了问题。