Ibis is a minimal implementation of a spell checker for use in Java projects.
Ibis requires Java 21. You can use it in your projects by including it as a Maven dependency:
<dependency>
<groupId>net.logicsquad</groupId>
<artifactId>ibis</artifactId>
<version>0.1</version>
</dependency>
Ibis ships with some built-in word lists, and you can start checking
text against a Dictionary containing these words:
Checker checker = new Checker();
String text = "Now is the time forr all good men to come to the aod of the party.";
var incorrect = checker.checkSpelling(text);
for (Word w : incorrect) {
System.out.println("w = " + w);
}
A Word object contains the start position of the word in the
original text, the incorrect word itself, and a list of suggestions
(based on phonetic matches with words in the dictionary).
w = Word [start=16, text=forr, suggestions=(fair, fairy, far...
w = Word [start=49, text=aod, suggestions=(ad, add, ado, aid...
You can add your own word lists to a Dictionary using the Builder
pattern:
Dictionary.Builder builder = Dictionary.builder().addWords().addWords("/words-1.txt").addWords("/words-2.txt.gz");
Dictionary dict = builder.build();
Checker checker = new Checker(dict);
In this example, words-1.txt and words-2.txt.gz are resources
available on the classpath at runtime. Word lists can be compressed
with gzip.
Ibis is currently fairly Anglocentric: it offers only English word
lists, and its support for localisation is limited to entry points
allowing you to supply a Locale for various objects. The only
Locale supported currently is Locale.ENGLISH. Support for other
languages should be straightforward to add if someone was keen.
By all means, open issue tickets and pull requests if you have something to contribute.
The landscape of open source spell checkers for Java is a little sparse. There are a number of options out there, though few of them appear to be under active development. (It's certainly possible that some are in a state where no more development is required.) Some of them appear to be solutions for rather specific use cases (such as those designed to co-operate with Swing components). All of them appear to be constrained by non-permissive licenses (usually the LGPL). While Ibis was, to some extent, inspired by the Jazzy project (and a fork of it), it is a clean-room design and licensed here under the more permissive 2-Clause BSD License. This extends to the word lists shipped with this project, all of which are used here either under the FreeBSD License or because they have been explicitly declared as in the public domain.