2 Star 1 Fork 0

Zhou_Chengy / pychatbot

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

小懒猫闲聊SDK

pypi MIT Licence unstable experimental deprecated Gitter

这是小懒猫AI推出的闲聊SDK1.1.3版本。这个SDK是pyd文件。

下载方式


pip install pychatbots

python -m pip install pychatbots

注意:1.采用pip下载不支持chat.pyd 2.使用module.pyd请先下载数据集

使用说明

chat.pyd:

示例:

-- coding: 'utf-8' --

 from chat import chats

 print("您需要什么帮助")

 while True:

     sel = input()

     q = chats.chat(None,sel,"your-bot-name",age,"x","like")

     print(q)
   
函数:

1.chats.chat(self,ji,name,age,xibe,like)

self填任何东西都可以,建议填None

ji填问题

name填机器人的名字

age填机器人的年龄

xibe填机器人的性别

like填机器人的爱好

module.pyd:

module:

以下modulename不包括文件后缀.h6

这个文件可以为用户定制机器人编写语料库,如编写客服机器人,聊天机器人

预训练模型在module-tool中

chat.h6:

这个模型包含404条语料(预训练模型)(通用)

hat.txt:

chat.h6对应文件数据集,自己编写数据集请参考

chat-1.h6:

内容与chat.h6部分相同(女),101条语料

语料库来源:

1.chatterbot库语料库

2.腾讯智能闲聊

3.网上图片

4.自编

数据集编写规范:

--问题--(分割符,可自定义,但chat.txt,chat-1.txt必须是空格) --答案1#答案2--(分割符,可自定义,但chat.txt,chat-1.txt必须是空格) --相似度--(如1,0.9,0.8,0.7,0.33)(不超过1)

函数

训练函数

module.train(self,g,filename,modulename,encoding)

self填None

g填分割符

filename填数据集文件名(是txt文件)

modulename是模型名

encoding填编码(如gbk,utf-8)

模型使用函数:

module.chat(self,q,modulename)

self填None

q填问题

modulename填模型名(不包括.h6)

modulename是模型名

Best:

module.Best_train(self,g,filename,modulename,encoding)

self填None

g是分割符

filename填数据集名

modulename填模型名

encoding填编码(如gbk,utf-8)

Best数据集:

问题(分割符,可自定义,但chat.txt,chat-1.txt必须是空格) 答案

module.Best_chat(self,g,q,modulename):

(其实module_tool中的预训练模型也可以用这个函数使用)

self不填

q填问题

modulename填模型名

q指问题

示例:


from pychatbots.module import module as chat

chat.train(None,' ','module-tool\chat','module-tool\chat')

while True:

    s = input()

    d = chat.chat(None,s,' ','module-tool\chat')#d = chat.Best_chat(None,s,' ','module-tool\chat

    print(d)
    

效果:


1次/##########/100%
    
......
    
    
你好吗
    
你好
bot:

这是一个基于module的扩展,可以让聊天机器人不那么傻

示例1:


from pychatbots.module import bot
    
from pychatbots.module import compare
    
from pychatbots.module import module
    
module.train(None,' ','module-tool\chat','module-tool\chat','utf-8')
    
Zhou = bot('Zhou')
    
Zhou.reset()
    
while True:
    
    s = input()
        
    a = Zhou.bot(s,'小智不能理解','module-tool\chat',',你烦不烦,None)
        
    print(a)
        

效果:


1次/##########/100%

......

你好

你好

你好

看到你好我都不知道要回什么那就回你好吧,你烦不烦

示例2(使用tihuan):


from pychatbots.module import bot
    
from pychatbots.module import compare
    
from pychatbots.module import module
    
module.train(None,' ','module-tool\chat','module-tool\chat','utf-8')
    
Zhou = bot('Zhou')
    
Zhou.reset()
    
while True:
    
    s = input()
        
    a = Zhou.bot(s,',小智','小智不能理解','module-tool\chat',None,['你烦不烦','到底你是机器人还是我是机器人'])
        
    print(a)

效果:


1次/##########/100%

......

你好(问)

你好(答)

你好(问)

你烦不烦(答)

你好(问)

到底你是机器人还是我是机器人(答)

这里的XXX可以自定义

XXX = bot(botname)

这个函数可以创建一个机器人,并生成XXX.bot文件

botname指生成XXX.bot的文件名,不包括.bot。

XX.bot(self,q,chu,Nonesay,modulename,again,tihuan)

self填None

q填问题

chu填对一些没用的词,系统会把这些词去掉。(chu参数可为列表(list)或字符串(str))

Nonesay是当调用Best_chat函数的返回结果是None时,返回的语句。(Nonesay参数可为列表(list)或字符串(str))

modulename指模型名(module)

again填再次问一个问题的后缀,不用可填None或False

tihuan填再次问一个问题的替换句,即可为列表(list)或字符串(不用可填None或False(注意:again和tihuan必须使用其中一项)

XXX.reset()

重置机器人

compare.pyd:

这是一个chat.pyd的依赖项

函数:

compare(str1,str2)

str1,str2填对比的文本

pyd文件:

pyd文件采用cython在windows编译的二进制文件,是无法进行反编译。

要求:

1.Python3.8.6rc1(必须要下载这个版本)

下载地址:Python

2.chat.pyd需要requests==2.24(查天气)

源代码:

本SDK的代码禁止个人获取,只提供服务。

使用方法:

1.下载SDK之后解压,建议下载zip文件(git下载可跳过)

2.把解压的文件改为您的项目名

3.编写py文件,导入参考示例

4.运行

用户使用协议:

希望各位用户遵守以下条款:

1.不将SDK发布到CSDN平台(CSDN平台下载很麻烦)

2.在fork此储存库同时,不能更改README.md文件

                      小懒猫AI

联系邮箱:earuil@outlook.com

gitee地址:gitee

一般是github先更新

MIT License Copyright (c) 2020 Zhou_Chengy Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

pychatbot是一个Python机器人框架 展开 收起
Python
MIT
取消

发行版 (8)

全部

贡献者

全部

近期动态

加载更多
不能加载更多了
Python
1
https://gitee.com/Zhou-Chengy/pychatbot.git
git@gitee.com:Zhou-Chengy/pychatbot.git
Zhou-Chengy
pychatbot
pychatbot
master

搜索帮助