语言: 中文
微件:
- 文本: "他在国会任职期间还曾与毒瘾作斗争。"
- 文本: "该审查全面评估了JLENS SuR和CPG设计成熟度与可信度的所有方面。"
- 文本: "莱特曼也为其工作人员的不当行为道歉。"
- 文本: "文森特·杰伊早些时候在10公里冬季两项短跑中为法国赢得了首枚金牌。"
- 文本: "如何将故事传达给观众,这取决于导演们的智慧。"
拼写错误检测器
数据集信息
针对此特定任务,我使用了NeuSpell语料库作为原始数据。
评估
以下表格总结了模型整体及每个类别的得分情况。
# |
精确率 |
召回率 |
F1分数 |
支持数 |
拼写错误 |
0.992332 |
0.985997 |
0.989154 |
416054.0 |
微平均 |
0.992332 |
0.985997 |
0.989154 |
416054.0 |
宏平均 |
0.992332 |
0.985997 |
0.989154 |
416054.0 |
加权平均 |
0.992332 |
0.985997 |
0.989154 |
416054.0 |
使用方法
您可以通过Transformers的NER(命名实体识别)管道使用此模型。
安装依赖
pip install transformers
使用管道进行预测
import torch
from transformers import AutoConfig, AutoTokenizer, AutoModelForTokenClassification
from transformers import pipeline
model_name_or_path = "m3hrdadfi/typo-detector-distilbert-en"
config = AutoConfig.from_pretrained(model_name_or_path)
tokenizer = AutoTokenizer.from_pretrained(model_name_or_path)
model = AutoModelForTokenClassification.from_pretrained(model_name_or_path, config=config)
nlp = pipeline('token-classification', model=model, tokenizer=tokenizer, aggregation_strategy="average")
sentences = [
"他在国会任职期间还曾与毒瘾作斗争。",
"该审查全面评估了JLENS SuR和CPG设计成熟度与可信度的所有方面。",
"莱特曼也为其工作人员的不当行为道歉。",
"文森特·杰伊早些时候在10公里冬季两项短跑中为法国赢得了首枚金牌。",
"如何将故事传达给观众,这取决于导演们的智慧。",
]
for sentence in sentences:
typos = [sentence[r["start"]: r["end"]] for r in nlp(sentence)]
detected = sentence
for typo in typos:
detected = detected.replace(typo, f'<i>{typo}</i>')
print(" [输入]: ", sentence)
print("[检测结果]: ", detected)
print("-" * 130)
输出:
[输入]: 他在国会任职期间还曾与毒瘾作斗争。
[检测结果]: 他在国会任职期间还曾与毒瘾作斗争。
----------------------------------------------------------------------------------------------------------------------------------
[输入]: 该审查全面评估了JLENS SuR和CPG设计成熟度与可信度的所有方面。
[检测结果]: 该审查全面评估了JLENS SuR和CPG设计成熟度与可信度的所有方面。
----------------------------------------------------------------------------------------------------------------------------------
[输入]: 莱特曼也为其工作人员的不当行为道歉。
[检测结果]: 莱特曼也为其工作人员的不当行为道歉。
----------------------------------------------------------------------------------------------------------------------------------
[输入]: 文森特·杰伊早些时候在10公里冬季两项短跑中为法国赢得了首枚金牌。
[检测结果]: 文森特·杰伊早些时候在10公里冬季两项短跑中为法国赢得了首枚金牌。
----------------------------------------------------------------------------------------------------------------------------------
[输入]: 如何将故事传达给观众,这取决于导演们的智慧。
[检测结果]: 如何将故事传达给观众,这取决于导演们的智慧。
----------------------------------------------------------------------------------------------------------------------------------
问题?
请在TypoDetector Issues仓库提交Github issue。