Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHieu Hoang <hieu@hoang.co.uk>2013-05-29 21:16:15 +0400
committerHieu Hoang <hieu@hoang.co.uk>2013-05-29 21:16:15 +0400
commit6249432407af8730c10bccc7894c0725fcaf5e47 (patch)
tree3ac1f094b9fdc199b04bc5ef209ce00e3596e37d /mert/Vocabulary.h
parent59bd7deb4b6b9c4f7b3b7dbb055783528fbc31ca (diff)
beautify
Diffstat (limited to 'mert/Vocabulary.h')
-rw-r--r--mert/Vocabulary.h69
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() {}
};