Add new words to the dictionary and ignore list at runtime

Hi,

I’m writing a text editor that uses LanguageTool as library. I’d like to give the user the possibility of adding words to the dictionary and to the ignore list (right click -> “Add word to the dictionary” or “Ignore this word”). These new words should also be available as suggestions. Is there a way to do this at runtime?

After taking a look at the LanguageTool API, I’ve found the method addWord(String) in the class org.languagetool.rules.spelling.hunspell.Hunspell.Dictionary. Is this the right way to add new words? How do I access the runtime dictionary? Is somehow referenced by JLanguageTool?

Thanks in advance.

I’ve documented this now at Java API - LanguageTool Wiki, but I think the words will not be used as suggestions. The addWord() method in org.languagetool.rules.spelling.hunspell.Hunspell.Dictionary might be the right method for some, but not for all languages. Also, it’s not accessible from outside or maybe it is somehow, but I wouldn’t recommend using it, it’s supposed to be internal.

That works! The users will now be able to decide if they want to ignore certain words. Thanks a lot

Is there any other way of adding new words to the dictionary at runtime that doesn’t involve using the addWord() method in org.languagetool.rules.spelling.hunspell.Hunspell.Dictionary and so that the new words are also used as suggestions? Initially the only two languages that would need to be supported are English and German.

Using the words also as suggestions is not yet supported at runtime. I see this makes sense, but I’m busy with other issues, so patches would be welcome.

Oki doki. I’ll see what I can do.