java 英文單詞糾正校正架構(Word Checker)

來源:互聯網
上載者:User

標籤:false   ofo   沒有   檢查   XML   spell   boolean   返回   nal   

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<String> 返回所有匹配的糾正列表
判斷單詞拼字是否正確 correctList(string, int limit) 待檢測的單詞, 返回列表的大小 返回指定大小的的糾正列表 列表大小 <= limit
測試例子

參見 []()

/** * 是否拼字正確 */@Testpublic void isCorrectTest() {    final String hello = "hello";    final String speling = "speling";    Assert.assertTrue(EnWordChecker.getInstance().isCorrect(hello));    Assert.assertFalse(EnWordChecker.getInstance().isCorrect(speling));}
/*** 返回首選結果*/@Testpublic 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. 預設返回所有 */@Testpublic void correctListTest() {    final String word = "goo";    List<String> stringList = EnWordChecker.getInstance().correctList(word);    Assert.assertTrue(stringList.size() > 0);}
/** * 預設糾正匹配列表 * 1. 預設返回所有 */@Testpublic 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

java 英文單詞糾正校正架構(Word Checker)

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.