diff options
author | Kenneth Heafield <kheafiel@cluster10.lti.ece.cmu.local> | 2011-03-09 13:40:23 -0500 |
---|---|---|
committer | Kenneth Heafield <kheafiel@cluster10.lti.ece.cmu.local> | 2011-03-09 13:40:23 -0500 |
commit | 75310799a6ee82b742ba69abab951a74fd0d19fc (patch) | |
tree | 7be29bf130d75b478ef1f2449ca67a7eddfe0781 /klm/lm/vocab.hh | |
parent | b2a018f6a5fc34dc799aa41a05a16eb79aa95de1 (diff) |
kenlm sync
Diffstat (limited to 'klm/lm/vocab.hh')
-rw-r--r-- | klm/lm/vocab.hh | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/klm/lm/vocab.hh b/klm/lm/vocab.hh index b584c82f..546c1649 100644 --- a/klm/lm/vocab.hh +++ b/klm/lm/vocab.hh @@ -2,6 +2,7 @@ #define LM_VOCAB__ #include "lm/enumerate_vocab.hh" +#include "lm/lm_exception.hh" #include "lm/virtual_interface.hh" #include "util/key_value_packing.hh" #include "util/probing_hash_table.hh" @@ -134,6 +135,15 @@ class ProbingVocabulary : public base::Vocabulary { EnumerateVocab *enumerate_; }; +void MissingUnknown(const Config &config) throw(SpecialWordMissingException); +void MissingSentenceMarker(const Config &config, const char *str) throw(SpecialWordMissingException); + +template <class Vocab> void CheckSpecials(const Config &config, const Vocab &vocab) throw(SpecialWordMissingException) { + if (!vocab.SawUnk()) MissingUnknown(config); + if (vocab.BeginSentence() == vocab.NotFound()) MissingSentenceMarker(config, "<s>"); + if (vocab.EndSentence() == vocab.NotFound()) MissingSentenceMarker(config, "</s>"); +} + } // namespace ngram } // namespace lm |