我发现 c api 可用于 aspell,但我想在 java 代码中使用它。我知道有 JNI 框架,我们可以通过它调用 c 库,但我无法在 aspell 情况下使用它,
谁能建议一些我可以在java程序中使用aspell拼写检查器的方法?我需要使用开源拼写检查器。
我尝试使用谷歌拼写检查器 api,但它们目前不可用。我认为谷歌已经停止了拼写检查免费服务。
我发现 c api 可用于 aspell,但我想在 java 代码中使用它。我知道有 JNI 框架,我们可以通过它调用 c 库,但我无法在 aspell 情况下使用它,
谁能建议一些我可以在java程序中使用aspell拼写检查器的方法?我需要使用开源拼写检查器。
我尝试使用谷歌拼写检查器 api,但它们目前不可用。我认为谷歌已经停止了拼写检查免费服务。
为可用的 Java 拼写检查器提供链接
爵士乐 - http://sourceforge.net/projects/jazzy/
JaSpell - http://sourceforge.net/projects/jaspell/
JOrtho - http://sourceforge.net/projects/jortho/
试试看。发表你的经历。
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 看起来非常有用,该线程描述了如何为不同语言生成字典:https ://superuser.com/questions/137957/how-to-convert-aspell-dictionary-to-simple-list-of-words