The Pspell library contains two main classes and several helper classes. The two main classes are PspellConfig and PspellMaster. The PspellConfig class is used to set initial defaults and to change spell checker specific options. The PspellManager class does most of the real work. It is responsible for managing the dictionaries, checking if a word is in the dictionary, and coming up with suggestions among other things. There are many helper classes the important ones are PspellWordList, PspellMutableWordList, Pspell*Emulation. The PspellWordList classes is used for accessing the suggestion list, as well as the personal and suggestion word list currently in use. The PspellMutableWordList is used to manage the personal, and perhaps other, word lists. The Pspell*Emulation classes are used for iterating through a list.
A C interface will also be proved as well as a few STL like helper classes for those who prefer more modern C++.
To use pspell your application should include ``pspell/pspell.h''. In order to insure that all the necessary libraries are linked in libtool should be used to perform the linking. When using libtool simply linking with ``-lpspell'' should be all that is necessary. When using shared libraries you might be able to simply link ``-lpspell'', but this is not recommended. This version of Pspell uses the CVS version of libtool (HEAD branch) however released versions of libtool should also work.
When your application first starts you should get a new configuration class with the command:
When ever a new document is created a new PspellManager class should also be created. There should be one manager class per document. To create a new manager class use the command.
If the word is not correct than the suggest method can be used to come up with likely replacements.
Finally, when the document is closed the PspellManager class should be deleted like so.
Methods that return a bool generally return false on error and true other wise. To find out what went wrong use the error_number and error_message methods. Unless otherwise stated methods that return a const char * will return null on error. The charter string returned is only valid until the next method which returns a const char * is called.
All methods are virtual and abstract, thus these classes are really abstract base classes. Therefore you cannot simply store the object directly. In order to make copies of the objects use the clone and assign methods if they are provided.
For the details of the various classes please see the header files. In the future I will generate class references using some automated tool.
An ``extrern C'' interface is also be provided. Method will be mapped to functions in the following manner.
<class name in lowercase with underscores>_<method name>([const] <Class> *, <other parameters if any>)For example ``PspellManager::lang_name() const'' would become ``pspell_manager_lang_name(const PspellManager *)''.
Methods that return a bool will instead return an int in the C interface.
An almost forward iterator class will be proved in a future version to wrap the Pspell*Emulation classes in. It is almost a forward iterator because two iterators will not be able to compared two each other unless it is to check if the iterator is at the end.
I strongly recommend the use of auto_ptr with all pointers returned. All pointers returned that you are reasonable to free, except for PspellManager, will be able to deleted with the standard C++ delete.
These helper classes will provided in separate header files so those who do not which to use them will not have to.
The following options are available to control which word list Pspell selects.
In order for Pspell to know which word lists to use each word list must have at least one *.pwli file in the pspell data directory which is normally /usr/local/share/pspell/, use ``pspell-config pkgdatadir'' to find out what it is on your system.
Each *.pwli has the the following name:
<language>[-[<spelling>][-<jargon>]]-<module>.pwliWhere <language> is the two letter language code, <spelling> is the particular spelling your interested in if the languages has multiple spelling in different parts of the world such as English, <jargon> is any extra informations to distinguish the word list from other ones with the same language and spelling, and <module> is the pspell module the main word list is for.
For example:
en-aspell.pwliNotice how if the spelling is left out but the jargon is not there needs to be two dashes between the language and the jargon.
en-american-aspell.pwli
en-american-medical-ispell.pwli
en-american-xlg-ispell.pwli
de--medical-ispell.pwli
Each *.pwli file then contains exactly one line which contains the full path of the main word list, white space, then any additional options to pass onto the module.
Two simple examples are included in the examples directory. Pspell must be installed before they will compile and at least one pspell module must be installed before they will run. To build the C++ example type ``make example-cxx'' and to build the C examples type ``make example-c''.
This method is needed because Aspell (http://aspell.sourceforge.net/) is able to learn from users misspellings. For example on the first pass a user misspells beginning as beging so aspell suggests:
begging, begin, being, Beijing, bagging, ....However the user then tries "begning" and aspell suggests
beginning, beaning, begging, ...so the user selects beginning. However than, latter on in the document the user misspelles it as begng (NOT beging). Normally aspell will suggest.
began, begging, begin, begun, ....However becuase it knows the user mispelled beginning as beging it will instead suggest:
beginning, began, begging, begin, begun ...I myself often misspelled beginning (and still do) as something close to begging and two many times wind up writing sentences such as "begging with ....".