Git Product home page Git Product logo

doctor-friende's Introduction

  • 视频中的demo演示网址用的上海服务器,低配,加载速度慢,各位轻虐~~ >.<

DEMO-GIF

image

image

说明

  • 本程序实现的是中文的医疗知识图谱的自动问答机器人MedicalKBQA,是基于新版的rasa-1.1.8版本及其支持的外部组件实现的,并使用了图数据库neo4j构建知识图谱。

  • 会话管理使用的是rasa-core,rasa的pipeline配置如下:

    pipeline:
    - name: "MitieNLP"
    model: "data/total_word_feature_extractor_zh.dat"
    - name: "JiebaTokenizer"
    dictionary_path: "jieba_userdict"
    - name: "MitieEntityExtractor"
    - name: "EntitySynonymMapper"
    - name: "RegexFeaturizer"
    - name: "MitieFeaturizer"
    - name: "SklearnIntentClassifier"
    
  • 注意: rasa-nlu和rasa-core已经合并成rasa

  • Rasa训练数据集的构造: 使用到了Chatito工具

配置环境(python==3.6.8)

  1. 下载zip包或者git clone

  2. 进入Doctor-Friende目录,conda记得activate环境

  3. 然后在命令行使用

    pip install -r requirements.txt
    
  4. 提示

    • 国内推荐使用镜像加速,比如:

      pip install -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt
      
    • 如果你有代理,可以在pip install命令后加上 --proxy=地址:端口

数据导入neo4j

  • 前提是已经有了可以连接的neo4j graph

  • 解压MedicalSpider/data/data.tar.gz,直接解压到MedicalSpider/data下,不要新建文件夹,则medical.json是所有数据的汇总, 将会被导入到你的知识图谱中

  • 修改MedicalSpider.process_data下的create_graph.py,把neo4j数据库的链接信息改成你自己的,然后运行该文件 (为了防止路径问题,建议使用pycharm打开本项目后运行)

  • 关于爬虫:爬虫实现是使用了scrapy库,若想运行,可以在Doctor-Friende目录下运行SpiderMain.py

  • 整体规模:

    • 13,635 nodes (5 labels)
    • 114,163 relationships (6 types)

image

  • 数据结构
实体类型 含义 数量 举例
Disease 疾病 6,143 百日咳\n头痛
Department 科室 54 儿科\n小儿内科
Drug 药品 1,124 硫辛酸片\n曲克芦丁片
Food 食物 378 蟹肉\n鱿鱼(干)
Symptom 疾病症状 5,936 角弓反张\n视网膜Roth斑
Total 总计 13,635 约1.3万实体量级

运行bot

  1. 下载用于mitie的模型文件放到chat/data文件夹下,百度网盘,密码:p4vx, 或者Mega云盘

  2. chat/MyActions下的actions.py中同样需要先把neo4j数据库的链接信息改成你自己的

  3. 打开2个终端,都cd到chat目录下,conda记得activate环境

  4. 一个终端(启动Action Server)

    rasa run actions --actions MyActions.actions --cors "*" -vv  
    
  5. 另一个终端(启动NLU & Core Server)

    rasa run --enable-api -m models/medical-final-m3/20190728-212653.tar.gz --port 5000 --endpoints config/endpoints.yml --credentials config/credentials.yml -vv
    
  6. 前端页面位于:ChatHTML

  7. 提示

    • 更推荐使用nohup等类似的方式在后台运行 ,并将控制台输出指向指定的文件。

参考

TODO

  • 上传前端项目
  • 写report
  • 优化readme

如有问题可以issue

doctor-friende's People

Contributors

pengyou200902 avatar

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.