Code Monkey home page Code Monkey logo

faqrobot's Introduction

FAQrobot

一个自动回复FAQ问题的聊天机器人。目前使用了简单词汇对比、词性权重、词向量3种相似度计算模式。输入符合格式的FAQ文本文件即可立刻使用。欢迎把无法正确区分的问题和FAQ文件发送到评论区。  

程序版本和依赖库

使用 python3 运行
jieba 分词使用的库
gensim  词向量使用的库,如果使用词向量vec模式,则需要载入

依赖的文件

如果使用词向量vec模式,需要下载3个文件:Word60.model,Word60.model.syn0.npy,Word60.model.syn1neg.npy
下载地址:http://pan.baidu.com/s/1kURNutT 密码:1tq1

FAQ知识库文件

FAQ文件包含想要告知用户的问答内容。
FAQ文件必须是UTF-8的无bom格式的文本文件。

注释:注释文字由#开头。(整个一行都是注释内容)

问答块格式如下:
【问题】问题标题(可以有1或多个,至少有1个。必须由"【问题】"开头。)
答案内容(可以有多行,必须紧跟着上面的【问题】,多行答案中间不能有空白的行。)
多个问答块之间可以用空白行分割
 
程序默认使用的是减肥问答FAQ文件。你可以载入自己编辑的FAQ文件。   展示效果  

主程序FAQrobot.py

直接运行该文件,即可对减肥问题进行问答。你可以载入自己的FAQ文件,请保证FAQ文件格式正确。
robot.answer(inputtxt,'simple_POS') 可得出输入问题的返回答案。
simType参数有如下模式:
simple:简单的对比相同词汇数量,得到句子相似度
simple_POS:简单的对比相同词汇数量,并对词性乘以不同的权重,得到句子相似度
vec:用词向量计算相似度,并对词性乘以不同的权重,得到句子相似度
all:调试模式,把以上几种模式的结果都显示出来,方便对比和调试

inputtxt 可输入的特殊文本命令:
-zsk 显示当前知识库
-s -1 查看上一个问句的结果和中间参数
-q -1 重复提问,把当一个问句当做输入
-reload 重新载入QA知识库

faqrobot's People

Contributors

linusp avatar ofooo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

faqrobot's Issues

基于nlp搞点大的,一起嘛?

你好,能看到这里的,肯定都是nlp同行了,我也一直在做NLP这块。
最近一段时间,想基于NLP ,从FAQ入手,搞点大的事儿,如有感兴趣的,
加微信[ybfl1321]一块了解下,备注下来自[github]。

希望可以一起搞点大事儿。。

不能使用vec模式

你好。
我尝试了一下你的模型,感觉很好。
就是vec模式模型加载出错了。

问答知识库开始载入
正在载入词向量
Traceback (most recent call last):
File "", line 1, in
File "/home/ree/workspace/easy-exprossion/modules/DL/FAQrobot/similarity.py", line 100, in init
self.reload()
File "/home/ree/workspace/easy-exprossion/modules/DL/FAQrobot/similarity.py", line 134, in reload
self.vecModel = Word2Vec.load(pp('./pack/Word60.model'))
File "/home/lsz/.virtualenvs/python3.5/lib/python3.5/site-packages/gensim/models/word2vec.py", line 1396, in load
model = super(Word2Vec, cls).load(*args, **kwargs)
File "/home/lsz/.virtualenvs/python3.5/lib/python3.5/site-packages/gensim/utils.py", line 272, in load
obj._load_specials(fname, mmap, compress, subname)
File "/home/lsz/.virtualenvs/python3.5/lib/python3.5/site-packages/gensim/models/word2vec.py", line 1420, in _load_specials
super(Word2Vec, self)._load_specials(*args, **kwargs)
File "/home/lsz/.virtualenvs/python3.5/lib/python3.5/site-packages/gensim/utils.py", line 302, in _load_specials
val = np.load(subname(fname, attrib), mmap_mode=mmap)
File "/home/lsz/.virtualenvs/python3.5/lib/python3.5/site-packages/numpy/lib/npyio.py", line 419, in load
pickle_kwargs=pickle_kwargs)
File "/home/lsz/.virtualenvs/python3.5/lib/python3.5/site-packages/numpy/lib/format.py", line 681, in read_array
array.shape = shape
ValueError: cannot reshape array of size 27787244 into shape (574288,60)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.