Scribus
Open source desktop publishing at your fingertips
Speller::Aspell::Suggest Class Reference

Class for interfacing with aspell. Should work with any aspell version from 0.60 onwards. More...

#include <suggest.h>

Public Member Functions

 Suggest (const std::string &lang=kDEF_LANG, const std::string &jargon=kDEF_JARGON, const std::string &encoding=kDEF_ENCODING) throw ( std::invalid_argument, std::runtime_error )
 Default constructor for spell-checking class. More...
 
 Suggest (const AspellDictInfo *dinfo, const std::string &encoding=kDEF_ENCODING) throw ( std::invalid_argument, std::runtime_error )
 Constructor for spell-checking class. More...
 
void addPersonalList (const std::string &word) throw ( std::runtime_error )
 Adds 'word' to personal list. More...
 
bool checkWord (const std::string &word)
 Spell-checks 'word'. More...
 
bool checkWord (const std::string &word, std::vector< std::string > &replacement, bool always=true) throw ( std::invalid_argument )
 Spell-checks 'word'. More...
 
void clearSessionList () throw ( std::runtime_error )
 Clears the current session word list. More...
 
std::string getConfigOpt (const std::string &opt)
 Gets value of configuration option, 'opt'. More...
 
void getConfigOpt (const std::string &opt, std::vector< std::string > &vals)
 Gets value of list type configuration option, 'opt'. More...
 
void ignoreWord (const std::string &word) throw ( std::runtime_error )
 Ignores 'word' for current session. More...
 
void listDicts (std::vector< AspellDictInfo > &vals)
 Obtains list of available aspell dictionaries. More...
 
void listDicts (std::vector< std::string > &vals)
 Obtains list of available aspell dictionaries. More...
 
void printMainList () throw ( std::invalid_argument )
 Prints main word list. WARNING: This causes a crash due to a bug in aspell, as of aspell version 0.60.3. More...
 
void printPersonalList () throw ( std::invalid_argument )
 Prints personal word list. More...
 
void printSessionList () throw ( std::invalid_argument )
 Prints session word list. More...
 
bool printSuggestions (const std::string &word, bool always=true) throw ( std::invalid_argument )
 Spell-checks word, and prints suggested replacements. More...
 
void resetConfig () throw ( std::invalid_argument, std::runtime_error )
 Resets aspell configuration, as per current set of parameters. More...
 
void resetConfig (const std::string &lang, const std::string &jargon, const std::string &encoding=kDEF_ENCODING) throw ( std::invalid_argument, std::runtime_error )
 Resets aspell configuration, as per current set of parameters, after resetting lang, jargon, and encoding. More...
 
void saveLists () throw ( std::runtime_error )
 Saves all word lists. More...
 
void setConfigOpt (const std::string &opt, const std::string &val) throw ( std::invalid_argument )
 Sets configuration option, 'opt' to value 'val'. More...
 
void StoreMainList (std::vector< std::string > &replacement) throw ( std::invalid_argument )
 Stores main word list. WARNING: This causes a crash due to a bug in aspell, as of aspell version 0.60.3. More...
 
void StorePersonalList (std::vector< std::string > &replacement) throw ( std::invalid_argument )
 Stores personal word list. More...
 
void StoreSessionList (std::vector< std::string > &replacement) throw ( std::invalid_argument )
 Stores session word list. More...
 

Static Public Attributes

static const char * kDICT_DELIM = "/"
 Delimiter between different components of formatted strings for aspell dictionary entries.
 
static const char * kEMPTY = "*"
 Used in place of an empty string for an aspell setting (currently, only jargon might be empty).
 
static const char * kDEF_LANG = "en"
 Default language for aspell dictionary.
 
static const char * kDEF_JARGON = ""
 Default jargon for aspell dictionary.
 
static const char * kDEF_ENCODING = "utf-8"
 Default character encoding for words.
 

Detailed Description

Class for interfacing with aspell. Should work with any aspell version from 0.60 onwards.

Author
Gora Mohanty gora@.nosp@m.srij.nosp@m.an.in

Constructor & Destructor Documentation

Speller::Aspell::Suggest::Suggest ( const std::string &  lang = kDEF_LANG,
const std::string &  jargon = kDEF_JARGON,
const std::string &  encoding = kDEF_ENCODING 
)
throw ( std::invalid_argument,
std::runtime_error
)

Default constructor for spell-checking class.

Author
Gora Mohanty gora@.nosp@m.srij.nosp@m.an.in
Parameters
langLanguage of aspell dictionary.
jargonJargon for aspell dictionary.
encodingCharacter encoding for words.
Return values
None
Exceptions
std::invalid_argumentfrom setConfig().
std::runtime_errorfor error in creating speller.
Speller::Aspell::Suggest::Suggest ( const AspellDictInfo *  dinfo,
const std::string &  encoding = kDEF_ENCODING 
)
throw ( std::invalid_argument,
std::runtime_error
)

Constructor for spell-checking class.

Author
Gora Mohanty gora@.nosp@m.srij.nosp@m.an.in
Parameters
dinfoaspell dictionary info structure.
encodingCharacter encoding of words.
Return values
None
Exceptions
std::invalid_argumentfrom setConfig().
std::runtime_errorfor error in creating speller.

Member Function Documentation

void Speller::Aspell::Suggest::addPersonalList ( const std::string &  word)
throw (std::runtime_error
)

Adds 'word' to personal list.

Author
Gora Mohanty gora@.nosp@m.srij.nosp@m.an.in
Parameters
wordWord to be added to personal list.
Return values
None
Exceptions
std::runtime_errorfor error in adding word.
bool Speller::Aspell::Suggest::checkWord ( const std::string &  word)

Spell-checks 'word'.

Author
Gora Mohanty gora@.nosp@m.srij.nosp@m.an.in
Parameters
wordWord to be checked.
Return values
trueif word is spelt correctly, else false
bool Speller::Aspell::Suggest::checkWord ( const std::string &  word,
std::vector< std::string > &  replacement,
bool  always = true 
)
throw (std::invalid_argument
)

Spell-checks 'word'.

Author
Gora Mohanty gora@.nosp@m.srij.nosp@m.an.in
Parameters
wordWord to be checked.
Return values
trueif word is spelt correctly, else false
Exceptions
std::invalid_argumentfrom storeWordList().
void Speller::Aspell::Suggest::clearSessionList ( )
throw (std::runtime_error
)

Clears the current session word list.

Author
Gora Mohanty gora@.nosp@m.srij.nosp@m.an.in
Parameters
None
Return values
None
Exceptions
std::runtime_errorfor error in clearing list.
std::string Speller::Aspell::Suggest::getConfigOpt ( const std::string &  opt)

Gets value of configuration option, 'opt'.

Author
Gora Mohanty gora@.nosp@m.srij.nosp@m.an.in
Parameters
optName of option whose setting is to be retrieved.
Return values
Valueof option setting.
void Speller::Aspell::Suggest::getConfigOpt ( const std::string &  opt,
std::vector< std::string > &  vals 
)

Gets value of list type configuration option, 'opt'.

Author
Gora Mohanty gora@.nosp@m.srij.nosp@m.an.in
Parameters
optName of option whose setting is to be retrieved.
valsVector for storing values for the list type object.
Return values
None.
void Speller::Aspell::Suggest::ignoreWord ( const std::string &  word)
throw (std::runtime_error
)

Ignores 'word' for current session.

Author
Gora Mohanty gora@.nosp@m.srij.nosp@m.an.in
Parameters
wordWord to be ignored.
Return values
None.
Exceptions
std::runtime_errorfor error in ignoring word.
void Speller::Aspell::Suggest::listDicts ( std::vector< AspellDictInfo > &  vals)

Obtains list of available aspell dictionaries.

Author
Gora Mohanty gora@.nosp@m.srij.nosp@m.an.in
Parameters
valsArray of aspell dictionary info structs
Return values
None
void Speller::Aspell::Suggest::listDicts ( std::vector< std::string > &  vals)

Obtains list of available aspell dictionaries.

Author
Gora Mohanty gora@.nosp@m.srij.nosp@m.an.in
Parameters
valsArray of formatted strings for aspell dictionary entries. Each has format <name>–<lang>–<jargon>–<size>
Return values
None
void Speller::Aspell::Suggest::printMainList ( )
throw (std::invalid_argument
)

Prints main word list. WARNING: This causes a crash due to a bug in aspell, as of aspell version 0.60.3.

Author
Gora Mohanty gora@.nosp@m.srij.nosp@m.an.in
Parameters
None
Return values
None.
Exceptions
std::invalid_argumentfrom printWordList().
void Speller::Aspell::Suggest::printPersonalList ( )
throw (std::invalid_argument
)

Prints personal word list.

Author
Gora Mohanty gora@.nosp@m.srij.nosp@m.an.in
Parameters
None
Return values
None.
Exceptions
std::invalid_argumentfrom printWordList().
void Speller::Aspell::Suggest::printSessionList ( )
throw (std::invalid_argument
)

Prints session word list.

Author
Gora Mohanty gora@.nosp@m.srij.nosp@m.an.in
Parameters
None
Return values
None.
Exceptions
std::invalid_argumentfrom printWordList().
bool Speller::Aspell::Suggest::printSuggestions ( const std::string &  word,
bool  always = true 
)
throw (std::invalid_argument
)

Spell-checks word, and prints suggested replacements.

Author
Gora Mohanty gora@.nosp@m.srij.nosp@m.an.in
Parameters
wordWord to be checked.
alwaysIf true, replacements are always printed, else only if word is mis-spelt.
Return values
trueif word is spelt correctly, else false
Exceptions
std::invalid_argumentfrom printWordList().
void Speller::Aspell::Suggest::resetConfig ( )
throw ( std::invalid_argument,
std::runtime_error
)

Resets aspell configuration, as per current set of parameters.

Author
Gora Mohanty gora@.nosp@m.srij.nosp@m.an.in
Parameters
None
Return values
None
Exceptions
std::invalid_argumentfrom setConfig().
std::runtime_errorfor error in recreating speller.
void Speller::Aspell::Suggest::resetConfig ( const std::string &  lang,
const std::string &  jargon,
const std::string &  encoding = kDEF_ENCODING 
)
throw ( std::invalid_argument,
std::runtime_error
)

Resets aspell configuration, as per current set of parameters, after resetting lang, jargon, and encoding.

Author
Gora Mohanty gora@.nosp@m.srij.nosp@m.an.in
Parameters
langLanguage of aspell dictionary.
jargonJargon for aspell dictionary.
encodingCharacter encoding for words.
Return values
None
Exceptions
std::invalid_argumentfrom setConfig().
std::runtime_errorfor error in recreating speller.
void Speller::Aspell::Suggest::saveLists ( )
throw (std::runtime_error
)

Saves all word lists.

Author
Gora Mohanty gora@.nosp@m.srij.nosp@m.an.in
Parameters
None
Return values
None
Exceptions
std::runtime_errorfor error in saving lists.
void Speller::Aspell::Suggest::setConfigOpt ( const std::string &  opt,
const std::string &  val 
)
throw (std::invalid_argument
)

Sets configuration option, 'opt' to value 'val'.

Author
Gora Mohanty gora@.nosp@m.srij.nosp@m.an.in
Parameters
optOption to be set.
valValue of option to be set.
Return values
None
Exceptions
std::invalid_argumentif option value is incorrect
void Speller::Aspell::Suggest::StoreMainList ( std::vector< std::string > &  replacement)
throw (std::invalid_argument
)

Stores main word list. WARNING: This causes a crash due to a bug in aspell, as of aspell version 0.60.3.

Author
Gora Mohanty gora@.nosp@m.srij.nosp@m.an.in
Parameters
None
Return values
None.
Exceptions
std::invalid_argumentfrom storeWordList().
void Speller::Aspell::Suggest::StorePersonalList ( std::vector< std::string > &  replacement)
throw (std::invalid_argument
)

Stores personal word list.

Author
Gora Mohanty gora@.nosp@m.srij.nosp@m.an.in
Parameters
None
Return values
None.
Exceptions
std::invalid_argumentfrom storeWordList().
void Speller::Aspell::Suggest::StoreSessionList ( std::vector< std::string > &  replacement)
throw (std::invalid_argument
)

Stores session word list.

Author
Gora Mohanty gora@.nosp@m.srij.nosp@m.an.in
Parameters
None
Return values
None.
Exceptions
std::invalid_argumentfrom storeWordList().

The documentation for this class was generated from the following files: