Question

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?

Was it helpful?

Solution

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
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top