word checker 本項目用於單詞拼寫檢查。html
Github 地址
本項目用於單詞拼寫檢查。java
錯誤提示支持 i18Ngit
JDK1.7 及其之後github
本項目已經上傳到 maven 倉庫,直接引入便可maven
<dependency> <groupId>com.github.houbb</groupId> <artifactId>word-checker</artifactId> <version>0.0.1</version> </dependency>
public static void main(String[] args) { final String result = EnWordChecker.getInstance().correct("speling"); System.out.println(result); }
結果爲測試
spelling
備註
全部方法爲 EnWordChecker
類下。code
功能 | 方法 | 參數 | 返回值 | 備註 |
---|---|---|---|---|
判斷單詞拼寫是否正確 | isCorrect(string) | 待檢測的單詞 | boolean | |
返回最佳糾正結果 | correct(string) | 待檢測的單詞 | String | 若是沒有找到能夠糾正的單詞,則返回其自己 |
判斷單詞拼寫是否正確 | correctList(string) | 待檢測的單詞 | List<String> | 返回全部匹配的糾正列表 |
判斷單詞拼寫是否正確 | 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 提供的原始英語單詞數據。xml
ENABLE word list