【发布时间】:2015-02-21 04:27:38
【问题描述】:
我很难开始这个确切的问题。以下是解决此问题的说明。
- ****第 4 部分:substitutebot-creator 除了能够匹配 句子的一部分,ChatterBot 应该改变什么的意思 它说取决于您的输入。编写一个名为 接受两个相同长度的句子的替代机器人创建者,FROM 和 TO,并输出一个 ChatterBot。 FROM和TO的第一项是 相关联的,如后两项、第三项等。 输出的 ChatterBot 将接受一个句子,SENT,并输出一个新的 SENT 中属于 FROM 的每个单词的句子 替换为 TO 中对应的单词。如果 FROM 和 TO 为空 句子,ChatterBot 将简单地返回 SENT****
例子:
STK> (define marions-vacay
(substitutebot-creator '(indonesia winter noodles)
'(texas summer steak)))
STK> (marions-vacay '(i visited indonesia this winter and ate noodles))
(i visited texas this summer and ate steak)
我尝试使用以下方法:
(define (substitutebot-creator from to)
(lambda (x) (substitutebot x from to)))
(define (substitutebot sent from to)
(define subby? (lambda (word) (equal? (recurse-first from) word)))
(cond ((and (empty? from)(empty? to)) sent)
((subby? (first sent))
(se (recurse-switch (first sent) from to
(count from)) (substitutebot (bf sent))))
(else (substitutebot (bf sent)))))
(define (recurse-first sent)
(if (empty? sent)
'()
((word(first sent))(recurse-first (bf sent)))))
但它不起作用。我想我在错误的道路上开始这个问题,所以我想知道开始这个问题的最佳方法是什么。几乎我如何成功地让聊天机器人创建另一个聊天机器人。
【问题讨论】:
标签: scheme