2007-03-14 15:42:35 +03:00
|
|
|
#include <iostream>
|
|
|
|
#include <string>
|
|
|
|
|
2012-11-14 18:18:53 +04:00
|
|
|
#include "moses/Timer.h"
|
|
|
|
#include "moses/InputFileStream.h"
|
2013-08-30 20:45:56 +04:00
|
|
|
#include "moses/FF/LexicalReordering/LexicalReorderingTable.h"
|
2007-03-14 15:42:35 +03:00
|
|
|
|
2008-10-09 03:51:26 +04:00
|
|
|
using namespace Moses;
|
|
|
|
|
2007-03-14 15:42:35 +03:00
|
|
|
Timer timer;
|
|
|
|
|
2011-02-24 16:57:11 +03:00
|
|
|
void printHelp()
|
|
|
|
{
|
2007-03-14 15:42:35 +03:00
|
|
|
std::cerr << "Usage:\n"
|
2011-02-24 16:57:11 +03:00
|
|
|
"options: \n"
|
|
|
|
"\t-in string -- input table file name\n"
|
|
|
|
"\t-out string -- prefix of binary table files\n"
|
|
|
|
"If -in is not specified reads from stdin\n"
|
|
|
|
"\n";
|
2007-03-14 15:42:35 +03:00
|
|
|
}
|
|
|
|
|
2011-02-24 16:57:11 +03:00
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
2007-03-14 15:42:35 +03:00
|
|
|
std::cerr << "processLexicalTable v0.1 by Konrad Rawlik\n";
|
|
|
|
std::string inFilePath;
|
|
|
|
std::string outFilePath("out");
|
2011-02-24 16:57:11 +03:00
|
|
|
if(1 >= argc) {
|
|
|
|
printHelp();
|
|
|
|
return 1;
|
2007-03-14 15:42:35 +03:00
|
|
|
}
|
2011-02-24 16:57:11 +03:00
|
|
|
for(int i = 1; i < argc; ++i) {
|
2007-03-14 15:42:35 +03:00
|
|
|
std::string arg(argv[i]);
|
2011-02-24 16:57:11 +03:00
|
|
|
if("-in" == arg && i+1 < argc) {
|
2007-03-14 15:42:35 +03:00
|
|
|
++i;
|
|
|
|
inFilePath = argv[i];
|
2011-02-24 16:57:11 +03:00
|
|
|
} else if("-out" == arg && i+1 < argc) {
|
2007-03-14 15:42:35 +03:00
|
|
|
++i;
|
|
|
|
outFilePath = argv[i];
|
|
|
|
} else {
|
|
|
|
//somethings wrong... print help
|
2011-02-24 16:57:11 +03:00
|
|
|
printHelp();
|
2007-03-14 15:42:35 +03:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
2011-02-24 16:57:11 +03:00
|
|
|
|
2013-05-22 13:25:25 +04:00
|
|
|
bool success = false;
|
|
|
|
|
2011-02-24 16:57:11 +03:00
|
|
|
if(inFilePath.empty()) {
|
|
|
|
std::cerr << "processing stdin to " << outFilePath << ".*\n";
|
2013-05-22 13:25:25 +04:00
|
|
|
success = LexicalReorderingTableTree::Create(std::cin, outFilePath);
|
2007-03-14 15:42:35 +03:00
|
|
|
} else {
|
2011-02-24 16:57:11 +03:00
|
|
|
std::cerr << "processing " << inFilePath<< " to " << outFilePath << ".*\n";
|
2007-03-14 15:42:35 +03:00
|
|
|
InputFileStream file(inFilePath);
|
2013-05-22 13:25:25 +04:00
|
|
|
success = LexicalReorderingTableTree::Create(file, outFilePath);
|
2007-03-14 15:42:35 +03:00
|
|
|
}
|
2013-05-22 13:25:25 +04:00
|
|
|
|
|
|
|
return (success ? 0 : 1);
|
2007-03-14 15:42:35 +03:00
|
|
|
}
|