#ifndef LIBWCCL_LEXICON_LEXICON_H #define LIBWCCL_LEXICON_LEXICON_H #include <boost/unordered_map.hpp> #include <boost/noncopyable.hpp> #include <libcorpus2/lexeme.h> // for unicodestring hash #include <libwccl/values/strset.h> namespace Wccl { class Lexicon : boost::noncopyable { public: typedef boost::unordered_map<UnicodeString, UnicodeString> map_t; Lexicon(const std::string& name, const std::string& file_name) : name_(name), file_name_(file_name) { BOOST_ASSERT(!name_.empty()); } /** * Translate given key to a value held in this lexicon. * @returns Value assigned to the given key, if present. * Empty UnicodeString if the key was not present. */ const UnicodeString& translate(const UnicodeString& key) const; /** * Translate given set of strings to corresponding values * from the lexicon. * Nonexisting keys will translate to nothing (will be removed * from output). */ boost::shared_ptr<StrSet> translate(const StrSet& set) const; std::string name() const { return name_; } std::string file_name() const { return file_name_; } bool has_key(const UnicodeString& key) const { return map_.find(key) != map_.end(); } void insert(const UnicodeString& key, const UnicodeString& value); void insert(const UnicodeString& key) { insert(key, key); } const map_t& map() const { return map_; } private: map_t map_; const std::string name_; const std::string file_name_; }; } /* end ns Wccl */ #endif // LIBWCCL_LEXICON_LEXICON_H