Segmentor with Noun Pharses
Project description
# Chunk分词器使用指南
环境依赖:python 3.6 (暂时只支持python3)
## 主要功能
1. 能够输出名词短语
2. 支持词性输出,名词短语词性为np
3. 支持名词短语以限定词+中心词的形式输出
>不可分割的名词短语是不存在限定词+中心词的形式的,如“机器学习”,而“经典机器学习算法”可拆解为“经典_机器学习_算法”
## Step 1 安装软件包
推荐新建一个python的虚拟环境(可跳过)
```bash
conda create --name chunk_seg python=3.6.5
```
### pip安装 (暂时不支持)
```bash
pip install git+https://www.github.com/keras-team/keras-contrib.git
pip install chunk_segmentor
```
### 手动安装
```bash
# 从SVN上拉取代码
svn checkout svn://116.247.109.58/rd/nlp/projects/nlu/chunk_segmentor
# 或者从github上拉取代码
git clone https://github.com/stevewyl/chunk_segmentor
cd chunk_segmentor
pip install -r requirements.txt
python setup.py install
```
### 额外安装
```bash
# 若你的机器安装有GPU,利用GPU加速预测速度
pip install tensorflow-gpu==1.9.0
```
## Step 2 如何使用
* 第一次import的时候,会自动下载模型和字典数据
* 支持单句和多句文本的输入格式,建议以列表的形式传入分词器
```python
from chunk_segmentor import Chunk_Segmentor
cutter = Chunk_Segmentor()
s = '这是一个能够输出名词短语的分词器,欢迎试用!'
res = [item for item in cutter.cut([s] * 10000)] # 1080ti上耗时12s
# 是否输出词性, 默认开启
cutter = Chunk_Segmentor(pos=True)
# 提供两个版本,accurate为精确版,fast为快速版但召回会降低一些,默认精确版
cutter = Chunk_Segmentor(mode='accurate')
cutter = Chunk_Segmentor(mode='fast')
# 限定词+中心词的形式, 默认关闭
cutter = Chunk_Segmentor(qualifier=True)
# 输出格式(词列表,词性列表,chunk集合)
[
(
['这', '是', '一个', '能够', '输出', '名词_短语', '的', '分词器', ',', '欢迎', '试用', '!'],
['rzv', 'vshi', 'mq', 'v', 'vn', 'np', 'ude1', 'np', 'w', 'v', 'v', 'w'],
['分词器', '名词_短语']
)
...
]
```
## Step 3 后续更新
若存在新的模型和字典数据,会提示你是否需要更新
## To-Do Lists
1. 提升限定词和名词短语的准确性 ---> 新的模型
2. char模型存在GPU调用内存溢出的问题 ---> 使用cnn提取Nchar信息来代替embedding的方式,缩小模型规模
3. 自定义字典
环境依赖:python 3.6 (暂时只支持python3)
## 主要功能
1. 能够输出名词短语
2. 支持词性输出,名词短语词性为np
3. 支持名词短语以限定词+中心词的形式输出
>不可分割的名词短语是不存在限定词+中心词的形式的,如“机器学习”,而“经典机器学习算法”可拆解为“经典_机器学习_算法”
## Step 1 安装软件包
推荐新建一个python的虚拟环境(可跳过)
```bash
conda create --name chunk_seg python=3.6.5
```
### pip安装 (暂时不支持)
```bash
pip install git+https://www.github.com/keras-team/keras-contrib.git
pip install chunk_segmentor
```
### 手动安装
```bash
# 从SVN上拉取代码
svn checkout svn://116.247.109.58/rd/nlp/projects/nlu/chunk_segmentor
# 或者从github上拉取代码
git clone https://github.com/stevewyl/chunk_segmentor
cd chunk_segmentor
pip install -r requirements.txt
python setup.py install
```
### 额外安装
```bash
# 若你的机器安装有GPU,利用GPU加速预测速度
pip install tensorflow-gpu==1.9.0
```
## Step 2 如何使用
* 第一次import的时候,会自动下载模型和字典数据
* 支持单句和多句文本的输入格式,建议以列表的形式传入分词器
```python
from chunk_segmentor import Chunk_Segmentor
cutter = Chunk_Segmentor()
s = '这是一个能够输出名词短语的分词器,欢迎试用!'
res = [item for item in cutter.cut([s] * 10000)] # 1080ti上耗时12s
# 是否输出词性, 默认开启
cutter = Chunk_Segmentor(pos=True)
# 提供两个版本,accurate为精确版,fast为快速版但召回会降低一些,默认精确版
cutter = Chunk_Segmentor(mode='accurate')
cutter = Chunk_Segmentor(mode='fast')
# 限定词+中心词的形式, 默认关闭
cutter = Chunk_Segmentor(qualifier=True)
# 输出格式(词列表,词性列表,chunk集合)
[
(
['这', '是', '一个', '能够', '输出', '名词_短语', '的', '分词器', ',', '欢迎', '试用', '!'],
['rzv', 'vshi', 'mq', 'v', 'vn', 'np', 'ude1', 'np', 'w', 'v', 'v', 'w'],
['分词器', '名词_短语']
)
...
]
```
## Step 3 后续更新
若存在新的模型和字典数据,会提示你是否需要更新
## To-Do Lists
1. 提升限定词和名词短语的准确性 ---> 新的模型
2. char模型存在GPU调用内存溢出的问题 ---> 使用cnn提取Nchar信息来代替embedding的方式,缩小模型规模
3. 自定义字典
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
chunk_segmentor-1.0.0.tar.gz
(1.7 MB
view hashes)