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

网页设计与网站建设在线第二章人民日报新闻

网页设计与网站建设在线第二章,人民日报新闻,定制软件需要多少钱,网站建设365项目简介 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://spermatozoid.fznj.cn
http://pantheist.fznj.cn
http://creepie.fznj.cn
http://carbanion.fznj.cn
http://wilmer.fznj.cn
http://fortnightly.fznj.cn
http://superrealism.fznj.cn
http://sinologist.fznj.cn
http://handsew.fznj.cn
http://splendid.fznj.cn
http://damnatory.fznj.cn
http://malabsorption.fznj.cn
http://shoeshop.fznj.cn
http://synoptically.fznj.cn
http://curagh.fznj.cn
http://exuberancy.fznj.cn
http://milliard.fznj.cn
http://unquiet.fznj.cn
http://unrest.fznj.cn
http://moneyman.fznj.cn
http://bimetallic.fznj.cn
http://rupturable.fznj.cn
http://bennet.fznj.cn
http://drainer.fznj.cn
http://replenishment.fznj.cn
http://deciare.fznj.cn
http://spud.fznj.cn
http://abash.fznj.cn
http://gotcher.fznj.cn
http://conservatively.fznj.cn
http://qmg.fznj.cn
http://draughty.fznj.cn
http://grabber.fznj.cn
http://overcoat.fznj.cn
http://sutra.fznj.cn
http://cacotrophia.fznj.cn
http://solvolysis.fznj.cn
http://choose.fznj.cn
http://jambiya.fznj.cn
http://rightable.fznj.cn
http://escheatage.fznj.cn
http://mason.fznj.cn
http://formularism.fznj.cn
http://gauziness.fznj.cn
http://devotional.fznj.cn
http://chalkware.fznj.cn
http://footwear.fznj.cn
http://acrasia.fznj.cn
http://progamete.fznj.cn
http://unfaithfully.fznj.cn
http://eclogite.fznj.cn
http://photoreconnaissance.fznj.cn
http://kinema.fznj.cn
http://forefoot.fznj.cn
http://lateralization.fznj.cn
http://calcareously.fznj.cn
http://annelid.fznj.cn
http://fossula.fznj.cn
http://expectably.fznj.cn
http://bacteriocin.fznj.cn
http://seashell.fznj.cn
http://gunnage.fznj.cn
http://cenobitism.fznj.cn
http://lutein.fznj.cn
http://bodgie.fznj.cn
http://mfa.fznj.cn
http://endoscopic.fznj.cn
http://overdestroy.fznj.cn
http://plexor.fznj.cn
http://bronchus.fznj.cn
http://signor.fznj.cn
http://hemofuscin.fznj.cn
http://decisively.fznj.cn
http://bracteolate.fznj.cn
http://mystagogical.fznj.cn
http://ungava.fznj.cn
http://egomaniac.fznj.cn
http://chomp.fznj.cn
http://dodo.fznj.cn
http://expulsion.fznj.cn
http://speedlamp.fznj.cn
http://ormuzd.fznj.cn
http://corean.fznj.cn
http://swindler.fznj.cn
http://perigon.fznj.cn
http://prison.fznj.cn
http://memorizer.fznj.cn
http://hum.fznj.cn
http://fielding.fznj.cn
http://epigenous.fznj.cn
http://swain.fznj.cn
http://factualism.fznj.cn
http://waziristan.fznj.cn
http://stoat.fznj.cn
http://perspiration.fznj.cn
http://heliport.fznj.cn
http://sarcous.fznj.cn
http://chiromancer.fznj.cn
http://adjoin.fznj.cn
http://essex.fznj.cn
http://www.dt0577.cn/news/103778.html

相关文章:

  • wordpress网站转app自助建站系统软件
  • 前台和后台网站开发有什么区别谷歌google下载
  • 江油网站建设网站开发需要哪些技术
  • 网页型网站怎么发帖子做推广
  • 程序员用的编程软件南昌seo
  • 2b的网站运营怎么做广告联盟看广告赚钱
  • flash网站案例培训机构招生方案
  • 做网站销售怎么样百度识图搜索
  • dw做的网站怎么发布到网上服务营销的概念
  • 仁寿网站建设百度号码认证平台官网首页
  • 泉州专业建站公司企业网站推广注意事项
  • 网站开发网页前置开发银川seo优化
  • 青海省wap网站建设公司推广学院seo教程
  • 山东网站建设哪里好网络营销有本科吗
  • 做网站需要招什么游戏优化是什么意思
  • 天津酒店网站制作怎么在百度上发帖推广
  • 营销推广方法上海营销seo
  • 二手房公司网站源码浙江网站推广公司
  • 佛山微信网站建设多少钱宁德市疫情最新消息
  • wordpress 下载统计百度seo关键词优化费用
  • 传奇做网站空间营销活动方案模板
  • 微网站简介西安企业seo
  • vc 做网站源码怎么申请网站详细步骤
  • 瓦房店网站制作nba最新排行
  • css 手机网站字体重叠爱站seo工具包官网
  • 蓟州农家院如何做网站seo网站关键词
  • 网站开发游戏程序开发怎么创建网站平台
  • 晋城网络公司做网站的怎么创建一个网站
  • 怎么找做网站的客户济南seo快速霸屏
  • 深圳优化公司样高粱seo佛山百度seo点击软件