Sinosoid / Automatically-extract-news-person-speech

新闻言论观点提取

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

新闻言论观点提取

输入: 一段新闻文本(Text)

输出: 文中每个人物/实体的观点(List)

地址: http://39.100.3.165:8871/

1. Getting Started

Prerequisites

flask
pyhanlp
gensim
scikit-learn
numpy
jieba
mxnet

Installing


  1. 获取项目源码 :

    # clone the repository
    $ git clone https://github.com/4keyboardman/StandpointExtract.git
    $ cd StandpointExtract
    
  2. 创建虚拟环境并激活:

    linux系统运行

    $ python3 -m venv venv
    $ . venv/bin/activate
    

    Windows系统运行cmd

    $ py -3 -m venv venv
    $ venv\Scripts\activate.bat
    
  3. 安装项目:

    $ pip install -e .
    
  4. 下载pyhanlp需要的数据包

    下载 data

    下载 jar与配置文件

    将下载好的文件直接放在pyhanlp模块的static文件夹下:

    StandpointExtract/venv/lib/python3.6/site-packages/pyhanlp/static/

    在终端执行如下命令进行测试,查看pyhanlp是否安装成功

    $ hanlp
    
    详情参考:https://github.com/hankcs/pyhanlp/wiki/%E6%89%8B%E5%8A%A8%E9%85%8D%E7%BD%AE
    

    如果报错,可以参考这里

  5. 下载模型文件放在项目根目录下

    下载模型:https://pan.baidu.com/s/1hE-p3YTMnxJebzthDNPJbw

    解压文件:

    $ unzip instance.zip
    

2. Running


linux系统运行:

$ export FLASK_APP=flaskr
$ export FLASK_ENV=development
$ flask run

Windows系统运行cmd:

> set FLASK_APP=flaskr
> set FLASK_ENV=development
> flask run

打开浏览器访问 http://127.0.0.1:5000

使用gunicorn启动:

$ gunicorn -D -w 1 -b 0.0.0.0:8871 "flaskr:create_app()"

api command

GET /cmd/model/reload: 重新加载instance中的模型文件
GET /cmd/extractor: 查询当前使用的判断句子结束的模型类型
GET /cmd/extractor/{type}: 设置判断句子结束的方法,type类型: 
    sif-句子相似度
    rnn-是否是人说的话
    mix-两者综合,默认类型

3. Start from scratch

如果想从零开始做一遍,你需要先参考Get-Data-from-MySQL-and-Train-Word2Vec训练词向量得到“说”的近义词

4. Acknowledgments


About

新闻言论观点提取

License:MIT License


Languages

Language:Python 78.6%Language:HTML 17.7%Language:CSS 3.4%Language:Shell 0.2%