diff options
author | Vlad Voicu <vladv@rosedu.org> | 2012-03-19 18:36:07 (GMT) |
---|---|---|
committer | vlad <vlad@tyrion.(none)> | 2012-10-13 13:55:45 (GMT) |
commit | 5f745ebd56014a68695ac4b6fe7fb5dc96e34384 (patch) | |
tree | 284e1c2f9d41844dd17046d859d2c68225cfa1d6 /SwifTools/SpellCheckerFactory.cpp | |
parent | b3948434495a18df5c4537a2a6e0feecc0805788 (diff) | |
download | swift-contrib-5f745ebd56014a68695ac4b6fe7fb5dc96e34384.zip swift-contrib-5f745ebd56014a68695ac4b6fe7fb5dc96e34384.tar.bz2 |
Addressed Kev's code review
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; } |