From 7b4dad0742cbe9220a1512cc15537b449d49d402 Mon Sep 17 00:00:00 2001 From: Kenneth Heafield Date: Wed, 30 Nov 2011 10:57:22 +0000 Subject: [PATCH] Nicer success message. Clean up some redundancy. --- lm/build_binary.cc | 50 ++++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/lm/build_binary.cc b/lm/build_binary.cc index 4511a8b9a2..e235cc5a31 100644 --- a/lm/build_binary.cc +++ b/lm/build_binary.cc @@ -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; }