Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/marian-nmt/marian.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHieu Hoang <hieuhoang@gmail.com>2017-02-20 16:01:44 +0300
committerHieu Hoang <hieuhoang@gmail.com>2017-02-20 16:01:44 +0300
commite39d0c8f8a309ad9565aff2fecf9e40fe68c0fde (patch)
treedd4dca80f1d228fe3eb7a985d819fa2baa13b20c /scripts
parentc316b64d34300685e4a3b182d60f62973591b4f9 (diff)
batching in client
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/client.py27
1 files changed, 18 insertions, 9 deletions
diff --git a/scripts/client.py b/scripts/client.py
index 0ffbd7a3..1ee43327 100755
--- a/scripts/client.py
+++ b/scripts/client.py
@@ -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 = ""