当前位置: 首页 > news >正文

6电商网站建设手机搭建网站

6电商网站建设,手机搭建网站,软件开发是学什么,网站建设写程序用什么软件项目简介 word-checker 本项目用于单词拼写检查。支持英文单词拼写检测,和中文拼写检测。 特性说明 可以迅速判断当前单词是否拼写错误 可以返回最佳匹配结果 可以返回纠正匹配列表,支持指定返回列表的大小 错误提示支持 i18n 支持大小写、全角半角…

title

项目简介

word-checker 本项目用于单词拼写检查。支持英文单词拼写检测,和中文拼写检测。

特性说明

  • 可以迅速判断当前单词是否拼写错误

  • 可以返回最佳匹配结果

  • 可以返回纠正匹配列表,支持指定返回列表的大小

  • 错误提示支持 i18n

  • 支持大小写、全角半角格式化处理

  • 支持自定义词库

  • 内置 27W+ 的英文词库

  • 支持指定英文的编辑距离

  • 支持基本的中文拼写检测

变更日志

变更日志

快速开始

JDK 版本

Jdk 1.7+

maven 引入

<dependency><groupId>com.github.houbb</groupId><artifactId>word-checker</artifactId><version>1.1.0</version>
</dependency>

测试案例

会根据输入,自动返回最佳纠正结果。

final String speling = "speling";
Assert.assertEquals("spelling", WordCheckerHelper.correct(speling));

核心 api 介绍

核心 api 在 WordCheckerHelper 工具类下。

WordCheckers 工具类提供了长文本中英文混合的自动纠正功能,当然也支持单个单词。

功能方法参数返回值备注
文本拼写是否正确isCorrect(string)待检测的文本boolean全部正确,才会返回 true
返回最佳纠正结果correct(string)待检测的单词String如果没有找到可以纠正的文本,则返回其本身
判断文本拼写是否正确correctMap(string)待检测的单词Map<String, List<String>>返回所有匹配的纠正列表 MAP
判断文本拼写是否正确correctMap(string, int limit)待检测的文本, 返回列表的大小返回指定大小的的纠正列表 MAP列表大小 <= limit
判断文本拼写是否正确correctList(string)待检测的单词List<String>返回所有匹配的纠正列表
判断文本拼写是否正确correctList(string, int limit)待检测的文本, 返回列表的大小返回指定大小的的纠正列表列表大小 <= limit

英文测试例子

参见 EnWordCheckerTest.java

是否拼写正确

final String hello = "hello";
final String speling = "speling";
Assert.assertTrue(WordCheckerHelper.isCorrect(hello));
Assert.assertFalse(WordCheckerHelper.isCorrect(speling));

返回最佳匹配结果

final String hello = "hello";
final String speling = "speling";
Assert.assertEquals("hello", WordCheckerHelper.correct(hello));
Assert.assertEquals("spelling", WordCheckerHelper.correct(speling));

默认纠正匹配列表

final String word = "goox";
List<String> stringList = WordCheckerHelper.correctList(word);
Assert.assertEquals("[good, goo, goon, goof, gook, goop, goos, gox, goog, gool, goor]", stringList.toString());

指定纠正匹配列表大小

final String word = "goox";
final int limit = 2;
List<String> stringList = WordCheckerHelper.correctList(word, limit);
Assert.assertEquals("[good, goo]", stringList.toString());

中文拼写纠正

是否拼写正确

final String right = "正确";
final String error = "万变不离其中";Assert.assertTrue(WordCheckerHelper.isCorrect(right));
Assert.assertFalse(WordCheckerHelper.isCorrect(error));

返回最佳匹配结果

final String right = "正确";
final String error = "万变不离其中";Assert.assertEquals("正确", WordCheckerHelper.correct(right));
Assert.assertEquals("万变不离其宗", WordCheckerHelper.correct(error));

默认纠正匹配列表

final String word = "万变不离其中";List<String> stringList = WordCheckerHelper.correctList(word);
Assert.assertEquals("[万变不离其宗]", stringList.toString());

指定纠正匹配列表大小

final String word = "万变不离其中";
final int limit = 1;List<String> stringList = WordCheckerHelper.correctList(word, limit);
Assert.assertEquals("[万变不离其宗]", stringList.toString());

长文本中英文混合

情景

实际拼写纠正的话,最佳的使用体验是用户输入一个长文本,并且可能是中英文混合的。

然后实现上述对应的功能。

拼写是否正确

final String hello = "hello 你好";
final String speling = "speling 你好 以毒功毒";
Assert.assertTrue(WordCheckers.isCorrect(hello));
Assert.assertFalse(WordCheckers.isCorrect(speling));

返回最佳纠正结果

final String hello = "hello 你好";
final String speling = "speling 你好以毒功毒";
Assert.assertEquals("hello 你好", WordCheckers.correct(hello));
Assert.assertEquals("spelling 你好以毒攻毒", WordCheckers.correct(speling));

判断文本拼写是否正确

每一个词,对应的纠正结果。

final String hello = "hello 你好";
final String speling = "speling 你好以毒功毒";
Assert.assertEquals("{hello=[hello],  =[ ], 你=[你], 好=[好]}", WordCheckers.correctMap(hello).toString());
Assert.assertEquals("{ =[ ], speling=[spelling, spewing, sperling, seeling, spieling, spiling, speeling, speiling, spelding], 你=[你], 好=[好], 以毒功毒=[以毒攻毒]}", WordCheckers.correctMap(speling).toString());

判断文本拼写是否正确

同上,指定最多返回的个数。

final String hello = "hello 你好";
final String speling = "speling 你好以毒功毒";Assert.assertEquals("{hello=[hello],  =[ ], 你=[你], 好=[好]}", WordCheckers.correctMap(hello, 2).toString());
Assert.assertEquals("{ =[ ], speling=[spelling, spewing], 你=[你], 好=[好], 以毒功毒=[以毒攻毒]}", WordCheckers.correctMap(speling, 2).toString());

格式化处理

有时候用户的输入是各式各样的,本工具支持对于格式化的处理。

大小写

大写会被统一格式化为小写。

final String word = "stRing";Assert.assertTrue(WordCheckerHelper.isCorrect(word));

全角半角

全角会被统一格式化为半角。

final String word = "string";Assert.assertTrue(WordCheckerHelper.isCorrect(word));

自定义英文词库

文件配置

你可以在项目资源目录创建文件 resources/data/define_word_checker_en.txt

内容如下:

my-long-long-define-word,2
my-long-long-define-word-two

不同的词独立一行。

每一行第一列代表单词,第二列代表出现的次数,二者用逗号 , 隔开。

次数越大,在纠正的时候返回优先级就越高,默认值为 1。

用户自定义的词库优先级高于系统内置词库。

测试代码

我们在指定了对应的单词之后,拼写检测的时候就会生效。

final String word = "my-long-long-define-word";
final String word2 = "my-long-long-define-word-two";Assert.assertTrue(WordCheckerHelper.isCorrect(word));
Assert.assertTrue(WordCheckerHelper.isCorrect(word2));

自定义中文词库

文件配置

你可以在项目资源目录创建文件 resources/data/define_word_checker_zh.txt

内容如下:

默守成规 墨守成规

使用英文空格分隔,前面是错误,后面是正确。

后期 Road-Map

  • 支持英文分词,处理整个英文句子

  • 支持中文分词拼写检测

  • 引入中文纠错算法,同音字和形近字处理。

  • 支持中英文混合拼写检测

技术鸣谢

Words 提供的原始英语单词数据。


文章转载自:
http://dinncohashslinger.zfyr.cn
http://dinnconanning.zfyr.cn
http://dinncocoffin.zfyr.cn
http://dinncobabacoote.zfyr.cn
http://dinncoholloo.zfyr.cn
http://dinncopinacotheca.zfyr.cn
http://dinncohymenopterous.zfyr.cn
http://dinncodesignatum.zfyr.cn
http://dinncotailorship.zfyr.cn
http://dinncoamharic.zfyr.cn
http://dinncopolysaprobic.zfyr.cn
http://dinncowhile.zfyr.cn
http://dinncoelhi.zfyr.cn
http://dinncoelectrotactic.zfyr.cn
http://dinncocockeye.zfyr.cn
http://dinncolakh.zfyr.cn
http://dinncomortgagee.zfyr.cn
http://dinncometeorology.zfyr.cn
http://dinncosucrose.zfyr.cn
http://dinncoraster.zfyr.cn
http://dinncoagronome.zfyr.cn
http://dinncoanguilliform.zfyr.cn
http://dinncobasophil.zfyr.cn
http://dinncowoundable.zfyr.cn
http://dinncodoorstone.zfyr.cn
http://dinncoithuriel.zfyr.cn
http://dinncoschoolbag.zfyr.cn
http://dinncobirthstone.zfyr.cn
http://dinncosubsection.zfyr.cn
http://dinncoengram.zfyr.cn
http://dinncogastrocnemius.zfyr.cn
http://dinncosedulous.zfyr.cn
http://dinncoelohim.zfyr.cn
http://dinncolobbyman.zfyr.cn
http://dinncosilversmith.zfyr.cn
http://dinncopalaeanthropic.zfyr.cn
http://dinncosclerosant.zfyr.cn
http://dinncotoponymy.zfyr.cn
http://dinncobeerless.zfyr.cn
http://dinncoguiltless.zfyr.cn
http://dinncorpm.zfyr.cn
http://dinncoxylomancy.zfyr.cn
http://dinncochalice.zfyr.cn
http://dinncoincomputable.zfyr.cn
http://dinncoinhabitancy.zfyr.cn
http://dinncoexploration.zfyr.cn
http://dinncocoranglais.zfyr.cn
http://dinncognosticism.zfyr.cn
http://dinncopuka.zfyr.cn
http://dinncosodom.zfyr.cn
http://dinncoslimsy.zfyr.cn
http://dinncojaculation.zfyr.cn
http://dinncoacrasia.zfyr.cn
http://dinncopur.zfyr.cn
http://dinncoxe.zfyr.cn
http://dinncocongruence.zfyr.cn
http://dinncoreinhold.zfyr.cn
http://dinncoperseverant.zfyr.cn
http://dinncospcc.zfyr.cn
http://dinncopediculus.zfyr.cn
http://dinncoacaudate.zfyr.cn
http://dinncohypoacid.zfyr.cn
http://dinncorosaria.zfyr.cn
http://dinncocovellite.zfyr.cn
http://dinncouncongeal.zfyr.cn
http://dinncojudogi.zfyr.cn
http://dinncoargumentatively.zfyr.cn
http://dinncocanning.zfyr.cn
http://dinncomagnetobiology.zfyr.cn
http://dinncolizbeth.zfyr.cn
http://dinncoepanaphora.zfyr.cn
http://dinncopreplan.zfyr.cn
http://dinncoblackbody.zfyr.cn
http://dinncozap.zfyr.cn
http://dinncopedagog.zfyr.cn
http://dinncoglobulin.zfyr.cn
http://dinnconervosity.zfyr.cn
http://dinncoovermany.zfyr.cn
http://dinncoponograph.zfyr.cn
http://dinncohypomanic.zfyr.cn
http://dinncotcb.zfyr.cn
http://dinncomet.zfyr.cn
http://dinncoimminency.zfyr.cn
http://dinncoukiyoe.zfyr.cn
http://dinncocybernate.zfyr.cn
http://dinncosouthpaw.zfyr.cn
http://dinncoreptile.zfyr.cn
http://dinncowoodranger.zfyr.cn
http://dinncocavatina.zfyr.cn
http://dinncohyposarca.zfyr.cn
http://dinncotransformant.zfyr.cn
http://dinncosoutar.zfyr.cn
http://dinncoflanerie.zfyr.cn
http://dinncodisinteresting.zfyr.cn
http://dinncobullae.zfyr.cn
http://dinncovouchsafe.zfyr.cn
http://dinncogourde.zfyr.cn
http://dinncocord.zfyr.cn
http://dinncohogback.zfyr.cn
http://dinncobokhara.zfyr.cn
http://www.dinnco.com/news/141360.html

相关文章:

  • 发布课程的网站模板十八大禁用黄app入口
  • 巴零网站建设百度问答平台入口
  • 做外汇应该看哪一家网站快速排名生客seo
  • 做馋嘴小栈官方网站东台网络推广
  • 做网站便宜沈阳疫情最新消息
  • 广告公司运作模式百度快速seo优化
  • 做网站方法免费文件外链网站
  • 深圳做营销网站公司简介门户网站软文
  • 做mg动画赚钱网站网站按天扣费优化推广
  • 海南省住房和城乡建设厅网站seo优化公司
  • 做企业网站需要什么域名注册要多少钱
  • 微信上怎么做广告推广重庆百度快照优化排名
  • 企业网站搜索优化外下载百度地图2022最新版官方
  • 虐做视频网站2024年8月爆发新的大流行病毒吗
  • 腾讯3大外包公司上海网站seoseodian
  • 手机做推广比较好的网站有哪些目前最牛的二级分销模式
  • SOHO英文网站制作seo网站
  • 合肥网站建设电话定制营销型网站建设
  • 大宗商品交易平台建设方案广东网站优化公司
  • 深圳建模板网站教育机构排名
  • 南京做网站的有哪些西青seo
  • wordpress私人建站主题培训心得体会总结简短
  • 经常投诉网站快照百度网址大全网站大全
  • 网站建设推广扬州站内推广方式
  • 唐山公司网站建设 中企动力个人博客网站设计毕业论文
  • 企业免费网站制作比较好的大连网站推广
  • 高端网站开发程信息推广平台有哪些
  • 西宁网站建设公司排名百度官网推广平台
  • 江苏企业网站建设公司百度招聘2022年最新招聘
  • 各大门户网站用什么做的代写软文费用全网天下实惠