Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我写了“hi hello”,在使用 chatterbot.preprocessors.clean_whitespace 清理空白之后,我想将我的输入显示为“hihello”,bt chatterbot 回复了我另一个答案。预处理后如何打印我的输入?
clean_whitespaceChatterBot 中的预处理器不会删除所有空格,只是前面、尾随和连续的空格。它会清理空白区域,但不会完全删除它。
clean_whitespace
听起来您想创建自己的预处理器。这可以像创建这样的函数一样简单:
def remove_whitespace(chatbot, statement): for character in ['\n', '\r', '\t', ' ']: statement.text = statement.text.replace(character, '') return statement