Using Aspell Library in java

2.3k Views Asked by At

I find that c api are available for the aspell but i would like to use it in java code. I know there is JNI framework by which we can call the c library but i am not able to use it in aspell case,

Can anyone suggest some methods by which i can use the aspell spelling checker in the java program ? I need to work on opensource spell checker.

I tried with the google spell checker api but they are not currently available. I think google has stopped spell checker free service.

2

There are 2 best solutions below

0
On

JavaSpell provides a wrapper to the aspell command for Java and is pretty simple to use.

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());
        }
    }
}

And this is how the output would look like:

wodrs --> [words, Woods, woods, word's, wards, ...]
easz --> [ease, easy, East, east]

Install by:

svn checkout http://javaspell.googlecode.com/svn/trunk/ javaspell-read-only
cd javaspell-read-only
mvn install -DskipTests

Jazzy looks pretty useful and this thread describes how to generate dictionaries for different languages: https://superuser.com/questions/137957/how-to-convert-aspell-dictionary-to-simple-list-of-words

1
On

Providing links for available spell checkers for Java

Jazzy - http://sourceforge.net/projects/jazzy/

JaSpell - http://sourceforge.net/projects/jaspell/

JOrtho - http://sourceforge.net/projects/jortho/

Try them. post your experience.