summaryrefslogtreecommitdiff
path: root/python/cdec
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
commit33dacc7534879b9d5b25f406194c7ae702b1e83b (patch)
tree8fb005ee538330070712bdd9b9ec4e896cedb591 /python/cdec
parentb1cddb13ce7a4aa050a9d4774254a8b474b3310c (diff)
stdout feedback
Diffstat (limited to 'python/cdec')
-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