I have managed to incorporate spell checking into my C# project using NHunspell. What I would like to do is actually add a word to the dictionary file. There is a method to do this inside of NHunspell which I believe is as follows:
// Add the word to the dictionary and carry on
using (Hunspell hunspell = new Hunspell(@"Dictionaries/en_GB.aff", @"Dictionaries/en_GB.dic"))
{
hunspell.Add("wordToAdd");
}
When I use this however it does not appear to actually do anything. Would anyone be able to suggest what it is I am doing wrong?
Thanks
I did not realise that adding a word using the .Add() method only allows that word to be used while the Hunspell object is alive. The word is not actually added to the external dictionary file. The way I combated this problem was to make use of a custom dictionary file. When a word is added by the user this word is stored in the new custom dictionary file. Now when my main spell checker function is called, before any words are checked all the words which are in the custom dictionary are added using the .Add() method. Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With