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/Ngram.h | |
parent | 59bd7deb4b6b9c4f7b3b7dbb055783528fbc31ca (diff) |
beautify
Diffstat (limited to 'mert/Ngram.h')
-rw-r--r-- | mert/Ngram.h | 59 |
1 files changed, 43 insertions, 16 deletions
diff --git a/mert/Ngram.h b/mert/Ngram.h index 6363c847c..521dc4928 100644 --- a/mert/Ngram.h +++ b/mert/Ngram.h @@ -13,8 +13,9 @@ namespace MosesTuning * typical accessors and mutaors, but we intentionally does not allow * erasing elements. */ -class NgramCounts { - public: +class NgramCounts +{ +public: // Used to construct the ngram map struct NgramComparator { bool operator()(const std::vector<int>& a, const std::vector<int>& b) const { @@ -45,7 +46,9 @@ class NgramCounts { /** * If the specified "ngram" is found, we add counts. * If not, we insert the default count in the container. */ - inline void Add(const Key& ngram) { m_counts[ngram]++; } + inline void Add(const Key& ngram) { + m_counts[ngram]++; + } /** * Return true iff the specified "ngram" is found in the container. @@ -60,34 +63,58 @@ class NgramCounts { /** * Clear all elments in the container. */ - void clear() { m_counts.clear(); } + void clear() { + m_counts.clear(); + } /** * Return true iff the container is empty. */ - bool empty() const { return m_counts.empty(); } + bool empty() const { + return m_counts.empty(); + } /** * Return the the number of elements in the container. */ - std::size_t size() const { return m_counts.size(); } + std::size_t size() const { + return m_counts.size(); + } - std::size_t max_size() const { return m_counts.max_size(); } + std::size_t max_size() const { + return m_counts.max_size(); + } // Note: This is mainly used by unit tests. - int get_default_count() const { return kDefaultCount; } + int get_default_count() const { + return kDefaultCount; + } - iterator find(const Key& ngram) { return m_counts.find(ngram); } - const_iterator find(const Key& ngram) const { return m_counts.find(ngram); } + iterator find(const Key& ngram) { + return m_counts.find(ngram); + } + const_iterator find(const Key& ngram) const { + return m_counts.find(ngram); + } - Value& operator[](const Key& ngram) { return m_counts[ngram]; } + Value& operator[](const Key& ngram) { + return m_counts[ngram]; + } - iterator begin() { return m_counts.begin(); } - const_iterator begin() const { return m_counts.begin(); } - iterator end() { return m_counts.end(); } - const_iterator end() const { return m_counts.end(); } + iterator begin() { + return m_counts.begin(); + } + const_iterator begin() const { + return m_counts.begin(); + } + iterator end() { + return m_counts.end(); + } + const_iterator end() const { + return m_counts.end(); + } - private: +private: const int kDefaultCount; boost::unordered_map<Key, Value> m_counts; }; |