summaryrefslogtreecommitdiff
path: root/python/cdec/sa/extract.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/cdec/sa/extract.py')
-rw-r--r--python/cdec/sa/extract.py11
1 files changed, 6 insertions, 5 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()