2015-10-23 20:33:12 +03:00
|
|
|
#include <iostream>
|
2015-10-26 00:20:55 +03:00
|
|
|
#include "System.h"
|
2015-10-24 01:19:31 +03:00
|
|
|
#include "Phrase.h"
|
2015-11-03 16:24:39 +03:00
|
|
|
#include "Search/Manager.h"
|
2015-10-24 04:02:50 +03:00
|
|
|
#include "moses/InputFileStream.h"
|
2015-10-27 18:46:37 +03:00
|
|
|
#include "moses/Parameter.h"
|
2015-10-23 20:33:12 +03:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
2015-11-06 14:51:14 +03:00
|
|
|
extern size_t g_numHypos;
|
|
|
|
|
2015-10-27 23:39:48 +03:00
|
|
|
istream &GetInputStream(Moses::Parameter ¶ms)
|
|
|
|
{
|
|
|
|
const Moses::PARAM_VEC *vec = params.GetParam("input-file");
|
|
|
|
if (vec) {
|
|
|
|
Moses::InputFileStream *stream = new Moses::InputFileStream(vec->at(0));
|
|
|
|
return *stream;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return cin;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-24 21:54:16 +03:00
|
|
|
int main(int argc, char** argv)
|
2015-10-23 20:33:12 +03:00
|
|
|
{
|
|
|
|
cerr << "Starting..." << endl;
|
|
|
|
|
2015-10-27 18:46:37 +03:00
|
|
|
Moses::Parameter params;
|
|
|
|
params.LoadParam(argc, argv);
|
|
|
|
System system(params);
|
2015-10-24 01:19:31 +03:00
|
|
|
|
2015-10-27 23:39:48 +03:00
|
|
|
istream &inStream = GetInputStream(params);
|
|
|
|
|
2015-10-24 01:19:31 +03:00
|
|
|
string line;
|
2015-10-27 23:39:48 +03:00
|
|
|
while (getline(inStream, line)) {
|
2015-10-24 01:19:31 +03:00
|
|
|
|
2015-10-26 00:20:55 +03:00
|
|
|
Manager mgr(system, line);
|
2015-10-24 15:31:43 +03:00
|
|
|
mgr.Decode();
|
2015-10-27 00:11:47 +03:00
|
|
|
|
|
|
|
const Hypothesis *bestHypo = mgr.GetBestHypothesis();
|
2015-10-29 18:29:14 +03:00
|
|
|
if (bestHypo) {
|
|
|
|
bestHypo->OutputToStream(cout);
|
2015-11-06 20:55:35 +03:00
|
|
|
cerr << *bestHypo;
|
2015-10-29 18:29:14 +03:00
|
|
|
}
|
|
|
|
else {
|
2015-11-06 20:55:35 +03:00
|
|
|
cerr << "NO TRANSLATION";
|
2015-10-29 18:29:14 +03:00
|
|
|
}
|
2015-10-27 01:12:29 +03:00
|
|
|
cout << endl;
|
2015-11-06 20:55:35 +03:00
|
|
|
cerr << endl;
|
2015-10-24 01:19:31 +03:00
|
|
|
}
|
2015-10-23 20:33:12 +03:00
|
|
|
|
2015-10-27 23:39:48 +03:00
|
|
|
if (inStream != cin) {
|
|
|
|
delete &inStream;
|
|
|
|
}
|
|
|
|
|
2015-11-06 14:51:14 +03:00
|
|
|
cerr << "g_numHypos=" << g_numHypos << endl;
|
2015-10-23 20:33:12 +03:00
|
|
|
cerr << "Finished" << endl;
|
|
|
|
}
|