Tagging-LSTM
介绍
NLP大作业:使用LSTM及CRF进行汉语的词类标注
环境
PyTorch 1.0.1
Python 3.7
Numpy, sklearn, matplotlib, seaborn
使用说明
1. 实验数据准备
使用北京大学人民日报语料库,已分词的txt文档被存放在 data 路径下, 其中 1998-01-2003_shuf.txt 为经过随机shuffle的数据。
2. 系统使用
加载checkpoint路径中训练好的模型,并按提示输入语句进行标注测试。
LSTM模型
python test.py --checkpoint checkpoint_lstm/ --gpu 0
BiLSTM模型
python test.py --bidirection --checkpoint checkpoint_bilstm/ --gpu 0
BiLSTM_CRF模型
python test.py --bidirection --crf --checkpoint checkpoint_bilstm_crf/ --gpu 0
测试示例:
python test.py --checkpoint checkpoint_lstm/ --gpu 1
Loading model...
请输入待标注句子(词语间用空格隔开,如“我 爱 你 中国”):我 爱 你 中国
输入句子: ['我', '爱', '你', '中国']
Running...
词类标注结果:
['r', 'v', '