diff options
author | Kenneth Heafield <github@kheafield.com> | 2012-09-12 15:07:44 +0100 |
---|---|---|
committer | Kenneth Heafield <github@kheafield.com> | 2012-09-12 15:07:44 +0100 |
commit | 173910593bf6bf3dc52902f99a683560d8c73942 (patch) | |
tree | 746ea920283178f3bf6b7f86e7b9e6b195821676 /klm/alone/vocab.hh | |
parent | 143ba7317dcaee3058d66f9e6558316f88f95212 (diff) |
Add the alone stuff, using a wrapper to the edge class.
Diffstat (limited to 'klm/alone/vocab.hh')
-rw-r--r-- | klm/alone/vocab.hh | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/klm/alone/vocab.hh b/klm/alone/vocab.hh new file mode 100644 index 00000000..3ac0f542 --- /dev/null +++ b/klm/alone/vocab.hh @@ -0,0 +1,34 @@ +#ifndef ALONE_VOCAB__ +#define ALONE_VOCAB__ + +#include "lm/word_index.hh" +#include "util/string_piece.hh" + +#include <boost/functional/hash/hash.hpp> +#include <boost/unordered_map.hpp> + +#include <string> + +namespace lm { namespace base { class Vocabulary; } } + +namespace alone { + +class Vocab { + public: + explicit Vocab(const lm::base::Vocabulary &backing); + + const std::pair<const std::string, lm::WordIndex> &FindOrAdd(const StringPiece &str); + + const std::pair<const std::string, lm::WordIndex> &EndSentence() const { return end_sentence_; } + + private: + typedef boost::unordered_map<std::string, lm::WordIndex> Map; + Map map_; + + const lm::base::Vocabulary &backing_; + + const std::pair<const std::string, lm::WordIndex> &end_sentence_; +}; + +} // namespace alone +#endif // ALONE_VCOAB__ |