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 | |
parent | b3948434495a18df5c4537a2a6e0feecc0805788 (diff) | |
download | swift-contrib-5f745ebd56014a68695ac4b6fe7fb5dc96e34384.zip swift-contrib-5f745ebd56014a68695ac4b6fe7fb5dc96e34384.tar.bz2 |
Addressed Kev's code review
Diffstat (limited to 'SwifTools')
-rw-r--r-- | SwifTools/HunspellChecker.cpp | 1 | ||||
-rw-r--r-- | SwifTools/SpellCheckerFactory.cpp | 11 | ||||
-rw-r--r-- | SwifTools/SpellCheckerFactory.h | 2 | ||||
-rw-r--r-- | SwifTools/SpellParser.h | 1 |
4 files changed, 12 insertions, 3 deletions
diff --git a/SwifTools/HunspellChecker.cpp b/SwifTools/HunspellChecker.cpp index fa5917a..f37b3e5 100644 --- a/SwifTools/HunspellChecker.cpp +++ b/SwifTools/HunspellChecker.cpp @@ -35,6 +35,7 @@ void HunspellChecker::getSuggestions(const std::string& word, std::vector<std::s list.push_back(suggestList[i]); free(suggestList[i]); } + free(suggestList); } void HunspellChecker::checkFragment(const std::string& fragment, PositionPairList& misspelledPositions) { 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; } diff --git a/SwifTools/SpellCheckerFactory.h b/SwifTools/SpellCheckerFactory.h index 5519db5..086ea66 100644 --- a/SwifTools/SpellCheckerFactory.h +++ b/SwifTools/SpellCheckerFactory.h @@ -15,6 +15,6 @@ namespace Swift { class SpellCheckerFactory { public: SpellCheckerFactory(); - SpellChecker* createSpellChecker(const char* affixPath, const char* dictPath); + SpellChecker* createSpellChecker(const std::string& dictFile); }; } diff --git a/SwifTools/SpellParser.h b/SwifTools/SpellParser.h index b18f4c2..3fe0613 100644 --- a/SwifTools/SpellParser.h +++ b/SwifTools/SpellParser.h @@ -21,6 +21,7 @@ namespace Swift { ID_CHAR = 4, }; typedef std::list<boost::tuple<int, int> > PositionPairList; + typedef boost::tuple<int, int> PositionPair; class SpellParser{ public: |