diff options
author | Kenneth Heafield <kenlm@kheafield.com> | 2012-03-11 21:47:38 +0400 |
---|---|---|
committer | Kenneth Heafield <kenlm@kheafield.com> | 2012-03-11 21:47:38 +0400 |
commit | 175b7aaf495963a8dd08525094073db06686adf8 (patch) | |
tree | c279eee1e5a3d3d7d417ec747091e184c418b7bf /lm/read_arpa.cc | |
parent | 0fc56ef7b602134b387b264c4b1ffe13e7ac40f8 (diff) |
KenLM c1dba12
- Reject NaNs
- Fix ChartState hashing (unused in Moses)
- Expose CreateOrThrow
- Minor portability improvement in getopt
Diffstat (limited to 'lm/read_arpa.cc')
-rw-r--r-- | lm/read_arpa.cc | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lm/read_arpa.cc b/lm/read_arpa.cc index 05f761be6..be6565992 100644 --- a/lm/read_arpa.cc +++ b/lm/read_arpa.cc @@ -7,6 +7,7 @@ #include <vector> #include <ctype.h> +#include <math.h> #include <string.h> #include <stdint.h> @@ -93,7 +94,11 @@ void ReadBackoff(util::FilePiece &in, ProbBackoff &weights) { case '\t': weights.backoff = in.ReadFloat(); if (weights.backoff == ngram::kExtensionBackoff) weights.backoff = ngram::kNoExtensionBackoff; - if ((in.get() != '\n')) UTIL_THROW(FormatLoadException, "Expected newline after backoff"); + { + int float_class = fpclassify(weights.backoff); + UTIL_THROW_IF(float_class == FP_NAN || float_class == FP_INFINITE, FormatLoadException, "Bad backoff " << weights.backoff); + } + UTIL_THROW_IF((in.get() != '\n'), FormatLoadException, "Expected newline after backoff"); break; case '\n': weights.backoff = ngram::kNoExtensionBackoff; |