diff options
author | Hieu Hoang <hieuhoang@gmail.com> | 2015-01-14 14:07:42 +0300 |
---|---|---|
committer | Hieu Hoang <hieuhoang@gmail.com> | 2015-01-14 14:07:42 +0300 |
commit | 05ead45e71916c5763c5c4b6375e2ca6838f3995 (patch) | |
tree | c279bd4aacfb31758720ffbaf5aaf62022574a52 /misc | |
parent | 91cb549ccf09fc33122f3d531f47c38ad0e99b3d (diff) |
beautify
Diffstat (limited to 'misc')
-rw-r--r-- | misc/CreateProbingPT.cpp | 33 | ||||
-rw-r--r-- | misc/QueryProbingPT.cpp | 59 | ||||
-rw-r--r-- | misc/prunePhraseTable.cpp | 16 |
3 files changed, 56 insertions, 52 deletions
diff --git a/misc/CreateProbingPT.cpp b/misc/CreateProbingPT.cpp index 2b0e8cd8a..b23427f30 100644 --- a/misc/CreateProbingPT.cpp +++ b/misc/CreateProbingPT.cpp @@ -3,26 +3,27 @@ -int main(int argc, char* argv[]){ +int main(int argc, char* argv[]) +{ - const char * is_reordering = "false"; + const char * is_reordering = "false"; - if (!(argc == 5 || argc == 4)) { - // Tell the user how to run the program - std::cerr << "Provided " << argc << " arguments, needed 4 or 5." << std::endl; - std::cerr << "Usage: " << argv[0] << " path_to_phrasetable output_dir num_scores is_reordering" << std::endl; - std::cerr << "is_reordering should be either true or false, but it is currently a stub feature." << std::endl; - //std::cerr << "Usage: " << argv[0] << " path_to_phrasetable number_of_uniq_lines output_bin_file output_hash_table output_vocab_id" << std::endl; - return 1; - } + if (!(argc == 5 || argc == 4)) { + // Tell the user how to run the program + std::cerr << "Provided " << argc << " arguments, needed 4 or 5." << std::endl; + std::cerr << "Usage: " << argv[0] << " path_to_phrasetable output_dir num_scores is_reordering" << std::endl; + std::cerr << "is_reordering should be either true or false, but it is currently a stub feature." << std::endl; + //std::cerr << "Usage: " << argv[0] << " path_to_phrasetable number_of_uniq_lines output_bin_file output_hash_table output_vocab_id" << std::endl; + return 1; + } - if (argc == 5) { - is_reordering = argv[4]; - } + if (argc == 5) { + is_reordering = argv[4]; + } - createProbingPT(argv[1], argv[2], argv[3], is_reordering); + createProbingPT(argv[1], argv[2], argv[3], is_reordering); - util::PrintUsage(std::cout); - return 0; + util::PrintUsage(std::cout); + return 0; } diff --git a/misc/QueryProbingPT.cpp b/misc/QueryProbingPT.cpp index 8a3441a0d..b7226e5ac 100644 --- a/misc/QueryProbingPT.cpp +++ b/misc/QueryProbingPT.cpp @@ -26,36 +26,37 @@ #include <unistd.h> #include <fcntl.h> -int main(int argc, char* argv[]) { - if (argc != 2) { - // Tell the user how to run the program - std::cerr << "Usage: " << argv[0] << " path_to_directory" << std::endl; - return 1; +int main(int argc, char* argv[]) +{ + if (argc != 2) { + // Tell the user how to run the program + std::cerr << "Usage: " << argv[0] << " path_to_directory" << std::endl; + return 1; + } + + QueryEngine queries(argv[1]); + + //Interactive search + std::cout << "Please enter a string to be searched, or exit to exit." << std::endl; + while (true) { + std::string cinstr = ""; + getline(std::cin, cinstr); + if (cinstr == "exit") { + break; + } else { + //Actual lookup + std::pair<bool, std::vector<target_text> > query_result; + query_result = queries.query(StringPiece(cinstr)); + + if (query_result.first) { + queries.printTargetInfo(query_result.second); + } else { + std::cout << "Key not found!" << std::endl; + } } + } - QueryEngine queries(argv[1]); - - //Interactive search - std::cout << "Please enter a string to be searched, or exit to exit." << std::endl; - while (true){ - std::string cinstr = ""; - getline(std::cin, cinstr); - if (cinstr == "exit"){ - break; - }else{ - //Actual lookup - std::pair<bool, std::vector<target_text> > query_result; - query_result = queries.query(StringPiece(cinstr)); - - if (query_result.first) { - queries.printTargetInfo(query_result.second); - } else { - std::cout << "Key not found!" << std::endl; - } - } - } - - util::PrintUsage(std::cout); + util::PrintUsage(std::cout); - return 0; + return 0; } diff --git a/misc/prunePhraseTable.cpp b/misc/prunePhraseTable.cpp index dcf8d73da..f6d608bc6 100644 --- a/misc/prunePhraseTable.cpp +++ b/misc/prunePhraseTable.cpp @@ -53,13 +53,15 @@ using namespace std; namespace po = boost::program_options; typedef multimap<float,string> Lines; -static void usage(const po::options_description& desc, char** argv) { - cerr << "Usage: " + string(argv[0]) + " [options] input-file output-file" << endl; - cerr << desc << endl; +static void usage(const po::options_description& desc, char** argv) +{ + cerr << "Usage: " + string(argv[0]) + " [options] input-file output-file" << endl; + cerr << desc << endl; } //Find top n translations of source, and send them to output -static void outputTopN(Lines lines, size_t maxPhrases, ostream& out) { +static void outputTopN(Lines lines, size_t maxPhrases, ostream& out) +{ size_t count = 0; for (Lines::const_reverse_iterator i = lines.rbegin(); i != lines.rend(); ++i) { out << i->second << endl; @@ -92,7 +94,7 @@ static void outputTopN(const Phrase& sourcePhrase, const multimap<float,const Ta out << endl; } }*/ -int main(int argc, char** argv) +int main(int argc, char** argv) { bool help; string input_file; @@ -112,7 +114,7 @@ int main(int argc, char** argv) cmdline_options.add(desc); po::variables_map vm; po::parsed_options parsed = po::command_line_parser(argc,argv). - options(cmdline_options).run(); + options(cmdline_options).run(); po::store(parsed, vm); po::notify(vm); if (help) { @@ -135,7 +137,7 @@ int main(int argc, char** argv) mosesargs.push_back("-f"); mosesargs.push_back(config_file); - boost::scoped_ptr<Parameter> params(new Parameter()); + boost::scoped_ptr<Parameter> params(new Parameter()); char** mosesargv = new char*[mosesargs.size()]; for (size_t i = 0; i < mosesargs.size(); ++i) { mosesargv[i] = new char[mosesargs[i].length() + 1]; |