chatterbot安装教程

chatterbot安装教程

前提安装好conda环境
win+R进入到cmd界面安装python虚拟环境

  1. 创建虚拟环境,必须使用3.7版本
conda create -n py_en python==3.7.3
  1. 激活环境
conda activate py_en
  1. 安装chatterbot
 pip install chatterbot
 pip install chatterbot-corpus
 pip install chatterbot
  1. 下载支持的压缩包
    下载地址: https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.3.1/en_core_web_sm-2.3.1.tar.gz

    文件存放目录我放在虚拟环境文件的上一级目录并运行下面命令

pip install en_core_web_sm-2.3.1.tar.gz  

在虚拟环境文件夹中搜索site-packages,进入到en_core_web_sm,将里面的文件夹en_core_web_sm-2.3.1改名为en并复制en,放到运行程序的项目里。

其中,我的en_core_web_sm文件夹目录是:
anaconda3/envs/python3.7.3/lib/python3.7/site-packages/en_core_web_sm
  1. 运行案例
from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer

chatbot = ChatBot('Ron Obvious')

# Create a new trainer for the chatbot
trainer = ChatterBotCorpusTrainer(chatbot)

# Train the chatbot based on the english corpus
trainer.train("chatterbot.corpus.chinese")
lineCounter = 1
# 开始对话
while True:
    print(chatbot.get_response(input("(" + str(lineCounter) + ") user:")))
    lineCounter += 1  
  • 9
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值