经验首页 前端设计 程序设计 Java相关 移动开发 数据库/运维 软件/图像 大数据/云计算 其他经验
当前位置:技术经验 » 程序设计 » 编程经验 » 查看文章
一键语法错误增强工具 ChineseErrorCorrector - TW-NLP
来源:cnblogs  作者:TW-NLP  时间:2024/7/29 9:44:00  对本文有异议

一键语法错误增强工具

      欢迎使用我最近开源的使用一键语法错误增强工具,该工具可以进行14种语法错误的增强,不同行业可以根据自己的数据进行错误替换,来训练自己的语法和拼写模型,希望推动行业文本纠错的发展,欢迎Star,14种错误如下所示:

 

每种错误类型,对应的使用方法,如下所示:

环境的安装

 

  1. pip install ChineseErrorCorrector

  

不同类型的数据增强

1.缺字漏字

 

  1. from ChineseErrorCorrector.dat import GrammarErrorDat
  2.  
  3. cged_tool = GrammarErrorDat()
  4. print(cged_tool.lack_word("小明住在北京"))
  5.  
  6. # 输出:小明在北京

  

 

2.错别字错误

  1. from ChineseErrorCorrector.dat import GrammarErrorDat
  2.  
  3. cged_tool = GrammarErrorDat()
  4. print(cged_tool.wrong_word("小明住在北京"))
  5. # 输出:小明住在北鲸

 

 

3.缺少标点

  1. from ChineseErrorCorrector.dat import GrammarErrorDat
  2.  
  3. cged_tool = GrammarErrorDat()
  4. print(cged_tool.lack_char("小明住在北京,热爱NLP。"))
  5. # 输出:小明住在北京热爱NLP。

  

 

4.错用标点

  1. from ChineseErrorCorrector.dat import GrammarErrorDat
  2.  
  3. cged_tool = GrammarErrorDat()
  4. print(cged_tool.wrong_char("小明住在北京"))
  5. # 输出:小明住在北京。热爱NLP。

  

 

5.主语不明

  1. from ChineseErrorCorrector.dat import GrammarErrorDat
  2.  
  3. cged_tool = GrammarErrorDat()
  4. print(cged_tool.unknow_sub("小明住在北京"))
  5. # 输出:住在北京

  

 

6.谓语残缺

  1. from ChineseErrorCorrector.dat import GrammarErrorDat
  2.  
  3. cged_tool = GrammarErrorDat()
  4. print(cged_tool.unknow_pred("小明住在北京"))
  5. # 输出:小明在北京

  

 

7.宾语残缺

  1. from ChineseErrorCorrector.dat import GrammarErrorDat
  2.  
  3. cged_tool = GrammarErrorDat()
  4. print(cged_tool.lack_obj("小明住在北京,热爱NLP。"))
  5. # 输出:小明住在北京,热爱。

  

 

8.其他成分残缺

  1. from ChineseErrorCorrector.dat import GrammarErrorDat
  2.  
  3. cged_tool = GrammarErrorDat()
  4. print(cged_tool.lack_others("小明住在北京,热爱NLP。"))
  5. # 输出:小明住北京,热爱NLP。

  

 

9.虚词多余

  1. from ChineseErrorCorrector.dat import GrammarErrorDat
  2.  
  3. cged_tool = GrammarErrorDat()
  4. print(cged_tool.red_fun("小明住在北京,热爱NLP。"))
  5. # 输出:小明所住的在北京,热爱NLP。

  

 

10.其他成分多余

  1. from ChineseErrorCorrector.dat import GrammarErrorDat
  2.  
  3. cged_tool = GrammarErrorDat()
  4. print(cged_tool.red_component("小明住在北京,热爱NLP。"))
  5. # 输出:小明住在北京,热爱NLP。,看着

  

 

11.主语多余

  1. from ChineseErrorCorrector.dat import GrammarErrorDat
  2.  
  3. cged_tool = GrammarErrorDat()
  4. print(cged_tool.red_sub("小明住在北京,热爱NLP。"))
  5. # 输出:小明住在北京,小明热爱NLP。

  

 

12.语序不当

  1. from ChineseErrorCorrector.dat import GrammarErrorDat
  2.  
  3. cged_tool = GrammarErrorDat()
  4. print(cged_tool.wrong_sentence_order("小明住在北京,热爱NLP。"))
  5. # 输出:热爱NLP。,小明住在北京

  

 

13.动宾搭配不当

  1. from ChineseErrorCorrector.dat import GrammarErrorDat
  2.  
  3. cged_tool = GrammarErrorDat()
  4. print(cged_tool.wrong_ver_obj("小明住在北京,热爱NLP。"))
  5. # 输出:None ,即无法进行此类错误的增强

  

 

14.其他搭配不当

  1. from ChineseErrorCorrector.dat import GrammarErrorDat
  2.  
  3. cged_tool = GrammarErrorDat()
  4. print(cged_tool.other_wrong("小明住在北京,热爱NLP。"))
  5. # 输出:None, 即无法进行此类错误的增强

  

代码地址:https://github.com/TW-NLP/ChineseErrorCorrector

 

原文链接:https://www.cnblogs.com/TW-NLP/p/18329367

 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号