From 33dacc7534879b9d5b25f406194c7ae702b1e83b Mon Sep 17 00:00:00 2001 From: mjdenkowski Date: Fri, 18 Apr 2014 15:23:17 -0400 Subject: stdout feedback --- python/cdec/sa/extract.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'python/cdec/sa') 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 -- cgit v1.2.3