From 629d84151f1288f8de11fc866c3960cfcf3ff0fd Mon Sep 17 00:00:00 2001 From: Patrick Simianer
Date: Wed, 27 May 2015 19:20:29 +0200
Subject: net: python extractor output
---
python/cdec/sa/extract.py | 11 ++++++-----
training/dtrain/dtrain_net.h | 3 ++-
training/dtrain/dtrain_net_interface.cc | 2 +-
3 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/python/cdec/sa/extract.py b/python/cdec/sa/extract.py
index 0f1f2246..cf87ff77 100644
--- a/python/cdec/sa/extract.py
+++ b/python/cdec/sa/extract.py
@@ -103,6 +103,7 @@ def stream_extract2(url):
from nanomsg import Socket, PAIR, PUB
socket = nanomsg.Socket(nanomsg.PAIR)
socket.bind(url)
+ sys.stderr.write("sending hello ...\n")
socket.send("hello")
while True:
line = socket.recv()
@@ -118,23 +119,23 @@ def stream_extract2(url):
if cmd.lower() == 'drop':
if online:
extractor.drop_ctx(context)
- sock.send('drop {}\n'.format(context))
+ sock.send('drop {}'.format(context))
else:
- sock.send('Error: online mode not set. Skipping line: {}\n'.format(line.strip()))
+ sock.send('Error: online mode not set. Skipping line: {}'.format(line.strip()))
# context ||| sentence ||| grammar_file
elif len(fields) == 3:
(context, sentence, grammar_file) = fields
with (gzip.open if compress else open)(grammar_file, 'w') as output:
for rule in extractor.grammar(sentence, context):
output.write(str(rule)+'\n')
- socket.send('{}\n'.format(grammar_file))
+ socket.send('{}'.format(grammar_file))
# context ||| sentence ||| reference ||| alignment
elif len(fields) == 4:
(context, sentence, reference, alignment) = fields
extractor.add_instance(sentence, reference, alignment, context)
- socket.send('learn {}\n'.format(context))
+ socket.send('learn {}'.format(context))
else:
- socket.send('Error: see README.md for stream mode usage. Skipping line: {}\n'.format(line.strip()))
+ socket.send('Error: see README.md for stream mode usage. Skipping line: {}'.format(line.strip()))
socket.send("off")
socket.close()
diff --git a/training/dtrain/dtrain_net.h b/training/dtrain/dtrain_net.h
index f6aa08b2..cbf171d6 100644
--- a/training/dtrain/dtrain_net.h
+++ b/training/dtrain/dtrain_net.h
@@ -43,7 +43,8 @@ dtrain_net_init(int argc, char** argv, po::variables_map* conf)
("k", po::value