java 英文单词拼写纠正框架(Word Checker)

Word Checker

本项目用于单词拼写检查。

项目简介

word checker 用于单词拼写检查。

Github 地址

特性说明

支持 i18n

错误提示支持 i18N

支持英文的单词纠错

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

  • 可以返回最佳匹配结果

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

后续将会添加的新功能

  • 英文单词支持自行定义

  • 中文单词的拼写是否正确功能添加

快速开始

JDK 版本

JDK1.7 及其以后

入门例子

maven 引入

本项目已经上传到 maven 仓库,直接引入即可

<dependency>
     <groupId>com.github.houbb</groupId>
     <artifactId>word-checker</artifactId>
    <version>0.0.1</version>
</dependency>
复制代码

测试案例

  • Main.java
public static void main(String[] args) {
    final String result = EnWordChecker.getInstance().correct("speling");
    System.out.println(result);
}
复制代码

结果为

spelling
复制代码

英文拼写纠错功能介绍

备注

所有方法为 EnWordChecker 类下。

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

测试例子

参见

/**
 * 是否拼写正确
 */
@Test
public void isCorrectTest() {
    final String hello = "hello";
    final String speling = "speling";
    Assert.assertTrue(EnWordChecker.getInstance().isCorrect(hello));
    Assert.assertFalse(EnWordChecker.getInstance().isCorrect(speling));
}
复制代码
/**
* 返回最佳匹配结果
*/
@Test
public void correctTest() {
    final String hello = "hello";
    final String speling = "speling";
    Assert.assertEquals("hello", EnWordChecker.getInstance().correct(hello));
    Assert.assertEquals("spelling", EnWordChecker.getInstance().correct(speling));
}
复制代码
/**
 * 默认纠正匹配列表
 * 1. 默认返回所有
 */
@Test
public void correctListTest() {
    final String word = "goo";
    List<String> stringList = EnWordChecker.getInstance().correctList(word);
    Assert.assertTrue(stringList.size() > 0);
}
复制代码
/**
 * 默认纠正匹配列表
 * 1. 默认返回所有
 */
@Test
public void correctListTest() {
    final String word = "goo";
    List<String> stringList = EnWordChecker.getInstance().correctList(word);
    Assert.assertTrue(stringList.size() > 0);
}
复制代码

技术鸣谢

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

文档参考

ENABLE word list

spell-correct

spellchecking

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值