Git Product home page Git Product logo

hunspellbridj's Introduction

HunspellBridJ

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

Travis-CI Status

Drone Status

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

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

hunspellbridj's People

Contributors

thomas-joiner avatar cselti avatar tmccombs avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.