pycorrector检测OCR错字实践

参考:https://github.com/shibing624/pycorrector/tree/master/examples/macbert

stopwords.txt 添加专业停用词,避免错误

设置自定义词典,避免将正确的词错误检测成错误的词

from pycorrector import Corrector
m = Corrector()
m.set_custom_word_freq(path='./dictionary/dict.txt')

在这里插入图片描述
去掉拼音纠正(OCR不会出现同音错误,更正后检测到的数量少了30%)
更改corrector.py内容,路径类似 miniconda/envs/env_name/lib/python3.x/site-packages/pycorrector/corrector.py
在这里插入图片描述
更改miniconda/envs/env_name/lib/python3.x/site-packages/pycorrector/proper_corrector.py文件
注释掉拼音相似度的比较 self.get_word_pinyin_similarity_score(word1, word2) 太慢,算了
在这里插入图片描述

vim xxxx/lib/python3.9/site-packages/pycorrector/data/proper_name.txt
设置专业名词词典

dector自定义频数
self.word_freq = {}
在这里插入图片描述

get_wor_simi
在这里插入图片描述

一些地名容易被检测成错字,提取地名代码

from pprint import pprint
from paddlenlp import Taskflow
schema = ['校区名称']   # Define the schema for entity extraction

ie = Taskflow('information_extraction', schema=schema)

pprint(ie("实验班,第一年在通州校区,第二至四年在平乐园校区")) 

在这里插入图片描述

from paddlenlp import Taskflow 报错ModuleNotFoundError: No module named ‘paddle.nn.layer.layers’

在使用paddle框架时,遇到以上错误,原因是版本不兼容。

paddlepaddle 2.4.2时 会自动安装最新版的paddlenlp 目前paddlenlp版本是2.6.0 该版本与paddlepaddle 2.4.2不兼容会报这个错

手动pip安装paddlenlp 2.5.2
参考:https://blog.csdn.net/qq_56942824/article/details/133776987

相关推荐

  1. python实现OCR

    2024-03-22 04:42:02       17 阅读
  2. SpringBoot+OCR 实现PDF 内容识别

    2024-03-22 04:42:02       42 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-03-22 04:42:02       19 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-03-22 04:42:02       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-03-22 04:42:02       19 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-03-22 04:42:02       20 阅读

热门阅读

  1. RabbitMQ docker 单机部署

    2024-03-22 04:42:02       21 阅读
  2. vue绑定key

    2024-03-22 04:42:02       19 阅读
  3. AGI的数据驱动:挖掘海量信息的价值与智慧

    2024-03-22 04:42:02       19 阅读
  4. Mysql批量更新: on duplicate key update

    2024-03-22 04:42:02       21 阅读
  5. [蓝桥杯2012] 罗马数字

    2024-03-22 04:42:02       23 阅读
  6. sqllab第29-33通关笔记

    2024-03-22 04:42:02       24 阅读
  7. [AIGC] Apache HTTP服务器:历史与使用

    2024-03-22 04:42:02       20 阅读
  8. 安卓面试题多线程 121-125

    2024-03-22 04:42:02       18 阅读
  9. 数据表示——原码/反码/补码/移码/浮点数

    2024-03-22 04:42:02       43 阅读
  10. 如何使用ubuntu samba服务器共享ubuntu文件

    2024-03-22 04:42:02       18 阅读