diff options
author | mjdenkowski <michael.j.denkowski@gmail.com> | 2014-04-18 15:23:17 -0400 |
---|---|---|
committer | mjdenkowski <michael.j.denkowski@gmail.com> | 2014-04-18 15:23:17 -0400 |
commit | 116e1ea2ece702cecf09c418df54c49711166204 (patch) | |
tree | a12c55dc44e6299db948834fc2a64e6329ee6eba /python/cdec | |
parent | 5d3585f705bdba1852540f4ed6edde3846ebb83b (diff) |
stdout feedback
Diffstat (limited to 'python/cdec')
-rw-r--r-- | python/cdec/sa/extract.py | 10 |
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 |