Search code examples
c++wxwidgetshunspell

Hunspell: Any solid example?


I have downloaded and compiled hunspell fine. Now I want to make a test app on wxWidgets and I started looking for example or tutorial. So far I have found none. I can find "example" executable but no code (May be hidden somewhere haven't found?). In whole internet for three days I have found nothing. The best I have found is this which is in language I cannot understand.

I will appreciate any simple example, pointer to tutorial or anything of value for that matter. Thanks a lot!


Solution

  • In case anyone still needs a solid example, at least on ubuntu the package libhunspell-dev provides one in /usr/share/doc/libhunspell-dev/examples/example.cxx.

    This file can also be found online, for example here: https://www.apt-browse.org/browse/ubuntu/precise/main/i386/libmythes-dev/2:1.2.2-1/file/usr/share/doc/libmythes-dev/examples/example.cxx

    Based on this, I created a very small example for C++:

    #include <iostream>
    #include <string>
    #include <hunspell/hunspell.hxx>
    
    int main()
    {
        Hunspell spell ("/usr/share/hunspell/en_US.aff", "/usr/share/hunspell/en_US.dic");
    
        std::cout << "Please enter one word:" << std::endl;
        std::string word;
        std::cin >> word;
    
        if (spell.spell(word.c_str()) == 0) {
                std::cout << "Spelling Error!";
        } else { 
                std::cout << "Correct Spelling!";
        }
    
        return 0;
    }