diff options
author | Hieu Hoang <hieu@hoang.co.uk> | 2013-05-29 21:16:15 +0400 |
---|---|---|
committer | Hieu Hoang <hieu@hoang.co.uk> | 2013-05-29 21:16:15 +0400 |
commit | 6249432407af8730c10bccc7894c0725fcaf5e47 (patch) | |
tree | 3ac1f094b9fdc199b04bc5ef209ce00e3596e37d /mert/Vocabulary.h | |
parent | 59bd7deb4b6b9c4f7b3b7dbb055783528fbc31ca (diff) |
beautify
Diffstat (limited to 'mert/Vocabulary.h')
-rw-r--r-- | mert/Vocabulary.h | 69 |
1 files changed, 46 insertions, 23 deletions
diff --git a/mert/Vocabulary.h b/mert/Vocabulary.h index 3ad42f46f..16c8698c6 100644 --- a/mert/Vocabulary.h +++ b/mert/Vocabulary.h @@ -4,7 +4,8 @@ #include <boost/unordered_map.hpp> #include <string> -namespace mert { +namespace mert +{ /** * A map to handle vocabularies to calculate @@ -12,8 +13,9 @@ namespace mert { * * TODO: replace this with more efficient data structure. */ -class Vocabulary { - public: +class Vocabulary +{ +public: typedef boost::unordered_map<std::string, int>::iterator iterator; typedef boost::unordered_map<std::string, int>::const_iterator const_iterator; @@ -28,32 +30,53 @@ class Vocabulary { */ bool Lookup(const std::string&str , int* v) const; - void clear() { m_vocab.clear(); } - - bool empty() const { return m_vocab.empty(); } - - std::size_t size() const { return m_vocab.size(); } - - iterator find(const std::string& str) { return m_vocab.find(str); } - const_iterator find(const std::string& str) const { return m_vocab.find(str); } - - int& operator[](const std::string& str) { return m_vocab[str]; } - - iterator begin() { return m_vocab.begin(); } - const_iterator begin() const { return m_vocab.begin(); } - iterator end() { return m_vocab.end(); } - const_iterator end() const { return m_vocab.end(); } - - private: + void clear() { + m_vocab.clear(); + } + + bool empty() const { + return m_vocab.empty(); + } + + std::size_t size() const { + return m_vocab.size(); + } + + iterator find(const std::string& str) { + return m_vocab.find(str); + } + const_iterator find(const std::string& str) const { + return m_vocab.find(str); + } + + int& operator[](const std::string& str) { + return m_vocab[str]; + } + + iterator begin() { + return m_vocab.begin(); + } + const_iterator begin() const { + return m_vocab.begin(); + } + iterator end() { + return m_vocab.end(); + } + const_iterator end() const { + return m_vocab.end(); + } + +private: boost::unordered_map<std::string, int> m_vocab; }; -class VocabularyFactory { - public: +class VocabularyFactory +{ +public: static Vocabulary* GetVocabulary(); static void SetVocabulary(Vocabulary* vocab); - private: +private: VocabularyFactory() {} virtual ~VocabularyFactory() {} }; |