Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Examples/Tutorials of Hunspell

I've tried looking through the documentation found on SourceForge with Hunspell, but I'm still lost. Are there any decent examples of hunspell that a C++ beginner would be able to follow? Failing that, are there any free/opensource spellcheckers that are easier to use?

like image 597
98cafe Avatar asked Jun 21 '13 17:06

98cafe


People also ask

How hunspell works?

The hunspell function is a high-level wrapper for finding spelling errors within a text document. It takes a character vector with text ( plain , latex , man , html or xml format), parses out the words and returns a list with incorrect words for each line.

How use hunspell Linux?

A line starting with '*' tells hunspell to insert the word into the user's dictionary (similar to the I command). A line starting with '&' tells hunspell to insert an all-lowercase version of the word into the user's dictionary (similar to the U command).

What is hunspell used for?

Hunspell is the spell checker library used by LibreOffice, OpenOffice, Mozilla Firefox, Google Chrome, Mac OS-X, InDesign, Opera, RStudio and many others. It provides a system for tokenizing, stemming and spelling in almost any language or alphabet.

What is hunspell en GB?

English (GB) dictionary for hunspell Hunspell is a spell checker and morphological analyzer library and program designed for languages with rich morphology and complex word compounding or character encoding.


1 Answers

I agree that their website is a little bit difficult to navigate and there aren't many tutorials for it.

I'd recommend just diving in.

For example here is some code for NHunspell, which is just the .net version. The code below is just the basic usage but should still be useful for someone getting started.

You can download dictionaries from the Open Office repository

//affPath = path to the .aff file
//dictPath = path to the .dic file

// create and load your hunspell object
NHunspell.Hunspell hunspell = new NHunspell.Hunspell(affPath, dicPath);

// want to add a word that is not part of the base dictionary? Sure, we can do that.
hunspell.Add("stackoverflow");

//lets check if a word is valid
bool isValid = hunpsell.Spell("stackoverflowed");
if(!isValid)
{
  //lets get some suggestions for this word
  List<String> suggestions = hunspell.Suggest("stackoverflowed");
  ...do stuff with your list of suggestions
}
like image 128
Kevin Avatar answered Oct 19 '22 22:10

Kevin