一个用于命名实体识别评估的python库
mi-ner的Python项目详细描述
矿工
用于ner(命名实体识别)计算的python库
利用该库,我们可以通过区分已知实体和未知实体来评价网络资源的性能。
支架
- 标记方案
- IOB2
- 生物能源
- 生物
- 指标
- 精度
- 回忆
- F1
要求
- Python3
- 赛顿
安装
pip install mi-ner
用法
样本
>>>fromminerimportMiner>>>answers=['B-PSN O O B-LOC O O O O'.split(' '),'B-PSN I-PSN O O B-LOC I-LOC O O O O'.split(' '),'S-PSN O O S-PSN O O B-LOC I-LOC E-LOC O O O O'.split(' ')]>>>predicts=['B-PSN O O B-LOC O O O O'.split(' '),'B-PSN B-PSN O O B-LOC I-LOC O O O O'.split(' '),'S-PSN O O O O O B-LOC I-LOC E-LOC O O O O'.split(' ')]>>>sentences=['花子 さん は 東京 に 行き まし た'.split(' '),'山田 太郎 君 は 東京 駅 に 向かい まし た'.split(' '),'花子 さん と ボブ くん は 東京 スカイ ツリー に 行き まし た'.split(' '),]>>>knowns={'PSN':['花子'],'LOC':['東京']}# known words (words included in training data)>>>m=Miner(answers,predicts,sentences,knowns)>>>m.default_report(True)precisionrecallf1_scorenumPSN0.5000.5000.5004LOC1.0001.0001.0003{'PSN':{'precision':0.5,'recall':0.5,'f1_score':0.5,'num':4},'LOC':{'precision':1.0,'recall':1.0,'f1_score':1.0,'num':3}}>>>m.return_predict_named_entities(){'known':{'PSN':['花子'],'LOC':['東京']},'unknown':{'PSN':['太郎','山田'],'LOC':['東京駅','東京スカイツリー']}}
方法
method | description |
---|---|
default_report(print_) | return result of named entity recognition. if print_=True, showing result |
known_only_report(print_) | return result of known named entity recognition. |
unknown_only_report(print_) | return result of unknown named entity recognition. |
return_predict_named_entities() | return named entities along predicted label(predicts). |
return_answer_named_entities() | return named entities along answer label(answer). |
return_miss_labelings() | return miss labeling sentences. |
segmentation_score(mode) | show parcentages of matching answer and predict labels. if ^{ |
许可证
麻省理工学院