diff options
Diffstat (limited to 'SwifTools/HunspellChecker.h')
-rw-r--r-- | SwifTools/HunspellChecker.h | 56 |
1 files changed, 43 insertions, 13 deletions
diff --git a/SwifTools/HunspellChecker.h b/SwifTools/HunspellChecker.h index 12c0485..2d4831e 100644 --- a/SwifTools/HunspellChecker.h +++ b/SwifTools/HunspellChecker.h @@ -4,24 +4,54 @@ * See Documentation/Licenses/BSD-simplified.txt for more information. */ +/* + * Copyright (c) 2016 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + +#pragma once + +#include <memory> +#include <string> +#include <unordered_map> #include <vector> + #include <boost/algorithm/string.hpp> -#include <boost/tuple/tuple.hpp> -#include <SwifTools/SpellChecker.h> +#include <boost/optional.hpp> -#pragma once +#include <SwifTools/SpellChecker.h> class Hunspell; namespace Swift { - class HunspellChecker : public SpellChecker { - public: - HunspellChecker(const char* affix_path, const char* dict_path); - virtual ~HunspellChecker(); - virtual bool isCorrect(const std::string& word); - virtual void getSuggestions(const std::string& word, std::vector<std::string>& list); - virtual void checkFragment(const std::string& fragment, PositionPairList& misspelledPositions); - private: - Hunspell* speller_; - }; + class HunspellChecker : public SpellChecker { + public: + HunspellChecker(); + virtual ~HunspellChecker(); + + virtual bool isAutomaticallyDetectingLanguage(); + + virtual void setActiveLanguage(const std::string& language); + virtual std::string activeLanguage() const; + virtual std::vector<std::string> supportedLanguages() const; + + virtual bool isCorrect(const std::string& word); + virtual void getSuggestions(const std::string& word, std::vector<std::string>& list); + virtual void checkFragment(const std::string& fragment, PositionPairList& misspelledPositions); + + private: + struct Dictionary { + std::string dicPath; + std::string affPath; + }; + + std::unordered_map<std::string, Dictionary> detectedDictionaries() const; + std::vector<std::string> hunspellDictionaryPaths() const; + + private: + std::unique_ptr<Hunspell> speller_; + boost::optional<std::string> activeLangauge_; + + }; } |