diff options
Diffstat (limited to 'SwifTools/SpellCheckerFactory.cpp')
-rw-r--r-- | SwifTools/SpellCheckerFactory.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/SwifTools/SpellCheckerFactory.cpp b/SwifTools/SpellCheckerFactory.cpp index 835cda9..6061d78 100644 --- a/SwifTools/SpellCheckerFactory.cpp +++ b/SwifTools/SpellCheckerFactory.cpp @@ -4,6 +4,8 @@ * See Documentation/Licenses/BSD-simplified.txt for more information. */ +#include <boost/filesystem/operations.hpp> + #include <SwifTools/SpellChecker.h> #include <SwifTools/HunspellChecker.h> #include <SwifTools/SpellCheckerFactory.h> @@ -17,9 +19,14 @@ namespace Swift { SpellCheckerFactory::SpellCheckerFactory() { } -SpellChecker* SpellCheckerFactory::createSpellChecker(const char* affixPath, const char* dictPath) { +SpellChecker* SpellCheckerFactory::createSpellChecker(const std::string& dictFile) { #ifdef HAVE_HUNSPELL - return new HunspellChecker(affixPath, dictPath); + std::string affixFile(dictFile); + boost::replace_all(affixFile, ".dic", ".aff"); + if ((boost::filesystem::exists(dictFile)) && (boost::filesystem::exists(affixFile))) { + return new HunspellChecker(affixFile.c_str(), dictFile.c_str()); + } + // If dictionaries don't exist disable the checker #endif return NULL; } |