mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-09-11 11:25:40 +03:00
Minor fixes. One for David Chiang who has files without initial newlines.
git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@4108 1f5c12ca-751b-0410-a591-d2e778427230
This commit is contained in:
parent
36db0ffe48
commit
61974ad75e
@ -7,7 +7,7 @@
|
||||
|
||||
set -e
|
||||
|
||||
for i in util/{bit_packing,ersatz_progress,exception,file_piece,murmur_hash,scoped,mmap} lm/{binary_format,config,lm_exception,model,quantize,read_arpa,search_hashed,search_trie,trie,virtual_interface,vocab}; do
|
||||
for i in util/{bit_packing,ersatz_progress,exception,file_piece,murmur_hash,scoped,mmap} lm/{bhiksha,binary_format,config,lm_exception,model,quantize,read_arpa,search_hashed,search_trie,trie,virtual_interface,vocab}; do
|
||||
g++ -I. -O3 -DNDEBUG $CXXFLAGS -c $i.cc -o $i.o
|
||||
done
|
||||
g++ -I. -O3 -DNDEBUG $CXXFLAGS lm/build_binary.cc {lm,util}/*.o -lz -o build_binary
|
||||
|
@ -31,15 +31,15 @@ const char kBinaryMagic[] = "mmap lm http://kheafield.com/code";
|
||||
void ReadARPACounts(util::FilePiece &in, std::vector<uint64_t> &number) {
|
||||
number.clear();
|
||||
StringPiece line;
|
||||
if (!IsEntirelyWhiteSpace(line = in.ReadLine())) {
|
||||
while (IsEntirelyWhiteSpace(line = in.ReadLine())) {}
|
||||
if (line != "\\data\\") {
|
||||
if ((line.size() >= 2) && (line.data()[0] == 0x1f) && (static_cast<unsigned char>(line.data()[1]) == 0x8b)) {
|
||||
UTIL_THROW(FormatLoadException, "Looks like a gzip file. If this is an ARPA file, pipe " << in.FileName() << " through zcat. If this already in binary format, you need to decompress it because mmap doesn't work on top of gzip.");
|
||||
}
|
||||
if (static_cast<size_t>(line.size()) >= strlen(kBinaryMagic) && StringPiece(line.data(), strlen(kBinaryMagic)) == kBinaryMagic)
|
||||
UTIL_THROW(FormatLoadException, "This looks like a binary file but got sent to the ARPA parser. Did you compress the binary file or pass a binary file where only ARPA files are accepted?");
|
||||
UTIL_THROW(FormatLoadException, "First line was \"" << line.data() << "\" not blank");
|
||||
UTIL_THROW(FormatLoadException, "first non-empty line was \"" << line << "\" not \\data\\.");
|
||||
}
|
||||
if ((line = in.ReadLine()) != "\\data\\") UTIL_THROW(FormatLoadException, "second line was \"" << line << "\" not \\data\\.");
|
||||
while (!IsEntirelyWhiteSpace(line = in.ReadLine())) {
|
||||
if (line.size() < 6 || strncmp(line.data(), "ngram ", 6)) UTIL_THROW(FormatLoadException, "count line \"" << line << "\"doesn't begin with \"ngram \"");
|
||||
// So strtol doesn't go off the end of line.
|
||||
|
Loading…
Reference in New Issue
Block a user