mosesdecoder/contrib/other-builds/moses2/Main.cpp

57 lines
1.1 KiB
C++
Raw Normal View History

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-10 14:28:17 +03:00
#include "TranslationTask.h"
2015-11-03 16:24:39 +03:00
#include "Search/Manager.h"
2015-11-13 02:18:30 +03:00
#include "legacy/InputFileStream.h"
2015-11-11 20:31:05 +03:00
#include "legacy/Parameter.h"
2015-11-13 00:58:07 +03:00
#include "legacy/ThreadPool.h"
2015-10-23 20:33:12 +03:00
using namespace std;
2015-11-10 19:27:28 +03:00
//extern size_t g_numHypos;
2015-11-06 14:51:14 +03:00
2015-11-11 20:31:05 +03:00
istream &GetInputStream(Parameter &params)
2015-10-27 23:39:48 +03:00
{
2015-11-11 20:31:05 +03:00
const PARAM_VEC *vec = params.GetParam("input-file");
2015-11-12 22:05:23 +03:00
if (vec && vec->size()) {
2015-11-13 02:18:30 +03:00
InputFileStream *stream = new InputFileStream(vec->at(0));
2015-10-27 23:39:48 +03:00
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-11-11 20:31:05 +03:00
Parameter params;
2015-10-27 18:46:37 +03:00
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-11-10 15:46:26 +03:00
cerr << "system.numThreads=" << system.numThreads << endl;
2015-11-13 00:58:07 +03:00
ThreadPool pool(system.numThreads);
2015-11-10 14:28:17 +03:00
2015-10-24 01:19:31 +03:00
string line;
2015-10-27 23:39:48 +03:00
while (getline(inStream, line)) {
2015-11-10 14:28:17 +03:00
boost::shared_ptr<TranslationTask> task(new TranslationTask(system, line));
2015-10-24 01:19:31 +03:00
2015-11-10 15:46:26 +03:00
pool.Submit(task);
//task->Run();
2015-10-24 01:19:31 +03:00
}
2015-10-23 20:33:12 +03:00
2015-11-10 15:46:26 +03:00
pool.Stop(true);
2015-10-27 23:39:48 +03:00
if (inStream != cin) {
delete &inStream;
}
2015-11-10 19:27:28 +03:00
// cerr << "g_numHypos=" << g_numHypos << endl;
2015-10-23 20:33:12 +03:00
cerr << "Finished" << endl;
}