summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authormjdenkowski <michael.j.denkowski@gmail.com>2014-04-18 15:23:17 -0400
committermjdenkowski <michael.j.denkowski@gmail.com>2014-04-18 15:23:17 -0400
commit116e1ea2ece702cecf09c418df54c49711166204 (patch)
treea12c55dc44e6299db948834fc2a64e6329ee6eba /python
parent5d3585f705bdba1852540f4ed6edde3846ebb83b (diff)
stdout feedback
Diffstat (limited to 'python')
-rw-r--r--python/cdec/sa/extract.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/python/cdec/sa/extract.py b/python/cdec/sa/extract.py
index 92d38af9..b6c11f05 100644
--- a/python/cdec/sa/extract.py
+++ b/python/cdec/sa/extract.py
@@ -75,23 +75,27 @@ def stream_extract():
if cmd.lower() == 'drop':
if online:
extractor.drop_ctx(context)
+ sys.stdout.write('drop {}\n'.format(context))
else:
- sys.stderr.write('Error: online mode not set. Skipping line: {}\n'.format(line.strip()))
+ sys.stdout.write('Error: online mode not set. Skipping line: {}\n'.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')
+ sys.stdout.write('{}\n'.format(grammar_file))
# context ||| sentence ||| reference ||| alignment
elif len(fields) == 4:
(context, sentence, reference, alignment) = fields
if online:
extractor.add_instance(sentence, reference, alignment, context)
+ sys.stdout.write('learn {}\n'.format(context))
else:
- sys.stderr.write('Error: online mode not set. Skipping line: {}\n'.format(line.strip()))
+ sys.stdout.write('Error: online mode not set. Skipping line: {}\n'.format(line.strip()))
else:
- sys.stderr.write('Error: see README.md for stream mode usage. Skipping line: {}\n'.format(line.strip()))
+ sys.stdout.write('Error: see README.md for stream mode usage. Skipping line: {}\n'.format(line.strip()))
+ sys.stdout.flush()
def main():
global online