summaryrefslogtreecommitdiff
path: root/python/cdec
diff options
context:
space:
mode:
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