IntroductionHunspell is a library that can be incorporated into an application to check the spelling of words. It can list suggestions for spelling a word that is not spelled correctly. Several well-known applications use it, including the word processor in the free LibreOffice suite.
Hunspell moduleSadly, Hunspell is not well documented; there is little information on the internet about how to use it in the C language so I developed a module - the HunspellModule.c - that implements functions to make the Hunspell library easy to use in Pelles C. It has been designed to work with Windows 11 (x64). HunspellModule.c includes functions that:
- Initialises the Hunspell object
- Frees the Hunspell object
- Checks the spelling of a word
- Adds a word to the 'run-time' dictionary
- Removes a word from the 'run-time' dictionary
- Suggests the spelling of a word
- Frees the list of suggested words
- Creates/loads a user dictionary
- Adds a word to the user dictionary.
(The 'run-time' dictionary mentioned above is not a permanent dictionary; it is a temporary dictionary that is cleared when the Hunspell object is freed.)
Instructions on how to use the HunspellModule.c are given in the attached zip file. This also includes:
- the 64 bit Hunspell DLL, Hunspellx64.dll
- a dictionary folder containing language files for the UK and USA (Others are available from https://share.across.net/s/mgCY9BABkCJgDYt)
- the HunspellModule.c file and its header file
- a sample program to demonstrate how to use HunspellModule.c
Sample programThe sample program has a menu item named Hunspell. This has two submenu items. The first Hunspell submenu item is
Get word to check. When selected it prompts the user to enter a word to check. If the word is correct then a message box confirms that word is in the dictionary. If the word is not in the dictionary (possibly because it has been mispelt) then a dialog box opens. This contains a list of suggested words that try to match the word that is not in the dictionary. The dialog box contains three buttons:
[li
]Add word to dictionary - this adds the word to a user dictionary. If the user dictionary does not exist then it is created and the word added to it[/li]
[li]
Ignore word - this adds the word to a run-time dictionary[/li]
[li]
Close - no action is taken with the word.[/li]
[/list]
The second Hunspell submenu item is
Remove word. When selected, the user is prompted to enter a word. This word will no longer be available in the run-time dictionary.
Functions not implementedThe Hunspell library includes several other functions, but the HunspellModule.c does not implement them.
AcknowledgementsWith thanks to Richard MacCutchan at Code Project for resolving an issue with adding a word to the run-time dictionary.