Giter VIP home page Giter VIP logo

word-checker's Introduction

项目简介

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

Maven Central Build Status Coverage Status

特性说明

支持 i18n

错误提示支持 i18N

支持英文的单词纠错

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

  • 可以返回最佳匹配结果

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

v0.0.2 新特性

  • 添加 WordCheckers 引导类

  • 支持自定义单词纠正实现

  • 支持忽略检查大小写

变更日志

快速开始

JDK 版本

JDK1.7 及其以后

入门例子

maven 引入

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

<dependency>
     <groupId>com.github.houbb</groupId>
     <artifactId>word-checker</artifactId>
    <version>0.0.2</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

测试例子

参见 EnWordCheckerTest.java

/**
 * 是否拼写正确
 */
@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);
}

深入学习

02-单词检查引导类

03-自定义单词检查实现

技术鸣谢

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

文档参考

ENABLE word list

spell-correct

spellchecking

word-checker's People

Contributors

houbb avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.