HunspellBridJ

This project is a binding for the Hunspell library for Java, using BridJ for the bindings.

License

License

GroupId

GroupId

com.atlascopco
ArtifactId

ArtifactId

hunspell-bridj
Last Version

Last Version

1.0.4
Release Date

Release Date

Type

Type

jar
Description

Description

HunspellBridJ
This project is a binding for the Hunspell library for Java, using BridJ for the bindings.
Project Organization

Project Organization

Atlas Copco Drilling Solutions
Source Code Management

Source Code Management

https://github.com/thomas-joiner/HunspellBridJ

Download hunspell-bridj

How to add to project

<!-- https://jarcasting.com/artifacts/com.atlascopco/hunspell-bridj/ -->
<dependency>
    <groupId>com.atlascopco</groupId>
    <artifactId>hunspell-bridj</artifactId>
    <version>1.0.4</version>
</dependency>
// https://jarcasting.com/artifacts/com.atlascopco/hunspell-bridj/
implementation 'com.atlascopco:hunspell-bridj:1.0.4'
// https://jarcasting.com/artifacts/com.atlascopco/hunspell-bridj/
implementation ("com.atlascopco:hunspell-bridj:1.0.4")
'com.atlascopco:hunspell-bridj:jar:1.0.4'
<dependency org="com.atlascopco" name="hunspell-bridj" rev="1.0.4">
  <artifact name="hunspell-bridj" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.atlascopco', module='hunspell-bridj', version='1.0.4')
)
libraryDependencies += "com.atlascopco" % "hunspell-bridj" % "1.0.4"
[com.atlascopco/hunspell-bridj "1.0.4"]

Dependencies

compile (1)

Group / Artifact Type Version
com.nativelibs4java : bridj jar 0.7.0

test (1)

Group / Artifact Type Version
junit : junit jar 4.10

Project Modules

There are no modules declared in this project.

HunspellBridJ

Project Status: Active - The project has reached a stable, usable state and is being actively developed.

Build Status

This library provides an API to interface with Hunspell using BridJ.

Free software licensed under GPL/LGPL/MPL tri-license, same as Hunspell itself.

Usage

Use of this library is very simple. First instantiate the Hunspell object.

Hunspell speller = new Hunspell("/path/to/dictionary.dic", "/path/to/affix.aff");

In order to check whether a word is correctly spelled, use the #spell(String) function.

String wordToCheck = ... // the word that you want to check
if ( speller.spell(word) ) {
  // word is spelled correctly
} else {
  // word is misspelled
}

If the word is spelled incorrectly, you will probably want to give the users some possible corrections for the word. In order to do so, use the #suggest(String) method.

String misspelledWord = ... // the word that you want suggestions for
List<String> suggestions = speller.suggest(misspelledWord);

If you maintain a user dictionary, you can add the words to Hunspell's runtime dictionary (not the dictionary file itself) using the #add(String) function.

String userWord = ... // word that isn't in the dictionary
speller.spell(userWord); // returns false
speller.add(userWord);
speller.spell(userWord); // returns true

A more advanced feature of Hunspell is that it allows you to add a word using another example word to define the affix flags that should apply to the word. As an example:

String userWord = ... // word that isn't in the dictionary, but is the same as "monkey"
speller.spell(userWord); // returns false
speller.addWithAffix(userWord, "monkey");
speller.spell(userWord); // all the following return true
speller.spell(userWord+"'s");
speller.spell(userWord+"s");
speller.spell(userWord+"ed");
speller.spell(userWord+"ing");

Note that this example is based on the dictionary used for the tests, if you use different dictionaries, the words that are added may not be the same.

If for whatever reason you need to remove the words that the user added, you can do so using the #remove(String) function.

String userWord = ... // word that has previously been added with #add or #addWithAffix
speller.spell(userWord); // returns true
speller.remove(userWord);
speller.spell(userWord); // returns false

Note that if the word was added with #addWithAffix(String,String), all affixed forms of the word will be removed as well.

Check the Javadocs for further information.

Supported Architectures

  • Linux x86
  • Linux x86_64
  • Windows x86
  • Windows x64
  • Mac OS X x86
  • Mac OS X x86_64

Maven

This project is available at Maven Central with the following dependency:

<dependency>
    <groupId>com.atlascopco</groupId>
    <artifactId>hunspell-bridj</artifactId>
    <version>1.0.4</version>
</dependency>

Versions

Version
1.0.4
1.0.3
1.0.2
1.0.1
1.0.0