diff options
author | Chris Dyer <cdyer@cs.cmu.edu> | 2011-01-25 22:30:48 +0200 |
---|---|---|
committer | Chris Dyer <cdyer@cs.cmu.edu> | 2011-01-25 22:30:48 +0200 |
commit | 931a036dc3cf9e1deafc10e78e94a0ebe3c8004f (patch) | |
tree | 9e1935fc4deafdbd04a8d38835c91b57f359cdee /klm/lm/read_arpa.hh | |
parent | bee6a3c3f6c54cf7449229488c6124dddc7e2f31 (diff) |
update kenlm
Diffstat (limited to 'klm/lm/read_arpa.hh')
-rw-r--r-- | klm/lm/read_arpa.hh | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/klm/lm/read_arpa.hh b/klm/lm/read_arpa.hh index 571fcbc5..4efdd29d 100644 --- a/klm/lm/read_arpa.hh +++ b/klm/lm/read_arpa.hh @@ -23,12 +23,14 @@ void ReadBackoff(util::FilePiece &in, ProbBackoff &weights); void ReadEnd(util::FilePiece &in); void ReadEnd(std::istream &in); +extern const bool kARPASpaces[256]; + template <class Voc> void Read1Gram(util::FilePiece &f, Voc &vocab, ProbBackoff *unigrams) { try { float prob = f.ReadFloat(); if (prob > 0) UTIL_THROW(FormatLoadException, "Positive probability " << prob); if (f.get() != '\t') UTIL_THROW(FormatLoadException, "Expected tab after probability"); - ProbBackoff &value = unigrams[vocab.Insert(f.ReadDelimited())]; + ProbBackoff &value = unigrams[vocab.Insert(f.ReadDelimited(kARPASpaces))]; value.prob = prob; ReadBackoff(f, value); } catch(util::Exception &e) { @@ -50,7 +52,7 @@ template <class Voc, class Weights> void ReadNGram(util::FilePiece &f, const uns weights.prob = f.ReadFloat(); if (weights.prob > 0) UTIL_THROW(FormatLoadException, "Positive probability " << weights.prob); for (WordIndex *vocab_out = reverse_indices + n - 1; vocab_out >= reverse_indices; --vocab_out) { - *vocab_out = vocab.Index(f.ReadDelimited()); + *vocab_out = vocab.Index(f.ReadDelimited(kARPASpaces)); } ReadBackoff(f, weights); } catch(util::Exception &e) { |