mirror of
https://github.com/marian-nmt/marian.git
synced 2024-11-30 21:39:52 +03:00
batching in client
This commit is contained in:
parent
c316b64d34
commit
e39d0c8f8a
@ -5,17 +5,26 @@ import time
|
||||
import sys
|
||||
|
||||
filePath = sys.argv[1]
|
||||
print filePath
|
||||
batchSize = int(sys.argv[2])
|
||||
#print filePath
|
||||
|
||||
with open(filePath) as f:
|
||||
batchCount = 0
|
||||
batch = ""
|
||||
for line in f:
|
||||
#print line
|
||||
line = line[:-1]
|
||||
#print line
|
||||
ws = create_connection("ws://localhost:8080/translate")
|
||||
ws.send(line)
|
||||
result=ws.recv()
|
||||
print(result)
|
||||
ws.close()
|
||||
#time.sleep(5)
|
||||
batchCount = batchCount + 1
|
||||
batch = batch + line
|
||||
if batchCount == batchSize:
|
||||
ws = create_connection("ws://localhost:8080/translate")
|
||||
|
||||
batch = batch[:-1]
|
||||
ws.send(batch)
|
||||
result=ws.recv()
|
||||
print(result)
|
||||
ws.close()
|
||||
#time.sleep(5)
|
||||
|
||||
batchCount = 0
|
||||
batch = ""
|
||||
|
||||
|
@ -39,6 +39,7 @@ boost::python::list translate(boost::python::list& in)
|
||||
|
||||
for(int lineNum = 0; lineNum < boost::python::len(in); ++lineNum) {
|
||||
std::string line = boost::python::extract<std::string>(boost::python::object(in[lineNum]));
|
||||
cerr << "line=" << line << endl;
|
||||
|
||||
maxiBatch->push_back(SentencePtr(new Sentence(god_, lineNum++, line)));
|
||||
|
||||
@ -77,7 +78,9 @@ boost::python::list translate(boost::python::list& in)
|
||||
for (auto&& result : results) {
|
||||
std::stringstream ss;
|
||||
Printer(god_, *result.get().get(), ss);
|
||||
output.append(ss.str());
|
||||
string str = ss.str();
|
||||
cerr << "output=" << str << endl;
|
||||
output.append(str);
|
||||
}
|
||||
|
||||
return output;
|
||||
|
Loading…
Reference in New Issue
Block a user