Skip to content

Commit

Permalink
Nicer success message. Clean up some redundancy.
Browse files Browse the repository at this point in the history
  • Loading branch information
kpu committed Nov 30, 2011
1 parent ec9db80 commit 7b4dad0
Showing 1 changed file with 26 additions and 24 deletions.
50 changes: 26 additions & 24 deletions lm/build_binary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -160,43 +160,45 @@ int main(int argc, char *argv[]) {
}
if (optind + 1 == argc) {
ShowSizes(argv[optind], config);
} else if (optind + 2 == argc) {
return 0;
}
const char *model_type, *from_file;
if (optind + 2 == argc) {
model_type = "probing";
from_file = argv[optind];
config.write_mmap = argv[optind + 1];
if (quantize || set_backoff_bits) ProbingQuantizationUnsupported();
ProbingModel(argv[optind], config);
} else if (optind + 3 == argc) {
const char *model_type = argv[optind];
const char *from_file = argv[optind + 1];
model_type = argv[optind];
from_file = argv[optind + 1];
config.write_mmap = argv[optind + 2];
if (!strcmp(model_type, "probing")) {
if (quantize || set_backoff_bits) ProbingQuantizationUnsupported();
ProbingModel(from_file, config);
} else if (!strcmp(model_type, "trie")) {
if (quantize) {
if (bhiksha) {
QuantArrayTrieModel(from_file, config);
} else {
QuantTrieModel(from_file, config);
}
} else {
Usage(argv[0]);
}
if (!strcmp(model_type, "probing")) {
if (quantize || set_backoff_bits) ProbingQuantizationUnsupported();
ProbingModel(from_file, config);
} else if (!strcmp(model_type, "trie")) {
if (quantize) {
if (bhiksha) {
QuantArrayTrieModel(from_file, config);
} else {
if (bhiksha) {
ArrayTrieModel(from_file, config);
} else {
TrieModel(from_file, config);
}
QuantTrieModel(from_file, config);
}
} else {
Usage(argv[0]);
if (bhiksha) {
ArrayTrieModel(from_file, config);
} else {
TrieModel(from_file, config);
}
}
} else {
Usage(argv[0]);
}
}
catch (const std::exception &e) {
std::cerr << "Built " << config.write_mmap << " successfully." << std::endl;
} catch (const std::exception &e) {
std::cerr << e.what() << std::endl;
return 1;
}

std::cerr << "KenLM build_binary SUCCESS" << std::endl;
return 0;
}

0 comments on commit 7b4dad0

Please sign in to comment.