JavaSpellは、Java の aspell コマンドのラッパーを提供し、非常に簡単に使用できます。
import java.io.IOException;
import java.util.List;
import nl.indenty.javaspell.ASpellException;
import nl.indenty.javaspell.ASpellWrapper;
import nl.indenty.javaspell.SpellCheckResult;
public class Dictionary {
public static void main(String[] args) throws IOException, ASpellException {
ASpellWrapper aSpell = new ASpellWrapper("en");
List<SpellCheckResult> results = aSpell.checkString("Spellchecker for English wodrs made easz");
for(SpellCheckResult result : results){
System.out.println(result.getWord() +" --> " +result.getSuggestions());
}
}
}
出力は次のようになります。
wodrs --> [words, Woods, woods, word's, wards, ...]
easz --> [ease, easy, East, east]
インストール方法:
svn checkout http://javaspell.googlecode.com/svn/trunk/ javaspell-read-only
cd javaspell-read-only
mvn install -DskipTests
Jazzy は非常に便利に見えます。このスレッドでは、さまざまな言語の辞書を生成する方法について説明しています。