00001 #include <iostream>
00002 #include <string>
00003
00004 #include "moses/Timer.h"
00005 #include "moses/InputFileStream.h"
00006 #include "moses/FF/LexicalReordering/LexicalReorderingTable.h"
00007
00008 using namespace Moses;
00009
00010 Timer timer;
00011
00012 void printHelp()
00013 {
00014 std::cerr << "Usage:\n"
00015 "options: \n"
00016 "\t-in string -- input table file name\n"
00017 "\t-out string -- prefix of binary table files\n"
00018 "If -in is not specified reads from stdin\n"
00019 "\n";
00020 }
00021
00022 int main(int argc, char** argv)
00023 {
00024 std::cerr << "processLexicalTable v0.1 by Konrad Rawlik\n";
00025 std::string inFilePath;
00026 std::string outFilePath("out");
00027 if(1 >= argc) {
00028 printHelp();
00029 return 1;
00030 }
00031 for(int i = 1; i < argc; ++i) {
00032 std::string arg(argv[i]);
00033 if("-in" == arg && i+1 < argc) {
00034 ++i;
00035 inFilePath = argv[i];
00036 } else if("-out" == arg && i+1 < argc) {
00037 ++i;
00038 outFilePath = argv[i];
00039 } else {
00040
00041 printHelp();
00042 return 1;
00043 }
00044 }
00045
00046 bool success = false;
00047
00048 if(inFilePath.empty()) {
00049 std::cerr << "processing stdin to " << outFilePath << ".*\n";
00050 success = LexicalReorderingTableTree::Create(std::cin, outFilePath);
00051 } else {
00052 std::cerr << "processing " << inFilePath<< " to " << outFilePath << ".*\n";
00053 InputFileStream file(inFilePath);
00054 success = LexicalReorderingTableTree::Create(file, outFilePath);
00055 }
00056
00057 return (success ? 0 : 1);
00058 }