Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mgiza.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Madl <git@abanbytes.eu>2016-04-08 12:58:43 +0300
committerDavid Madl <git@abanbytes.eu>2016-04-08 12:58:43 +0300
commitcebc0decb176ebf39280b352c49dc759fce95142 (patch)
tree6bc3a563bb18a415a96036a976ca79c2e3593af5
parent26cff2c62d859dd5c40aeab96c28847c5b3a743a (diff)
Fix merge_alignment.py encoding issue with Python 3
Fixes the following problem when using Python 3: Traceback (most recent call last): File "/fs/lofn0/dmadl/software/mgiza/mgizapp/bin/merge_alignment.py", line 118, in <module> main() File "/fs/lofn0/dmadl/software/mgiza/mgizapp/bin/merge_alignment.py", line 92, in main "%s%s%s" % (sents[i][0], sents[i][1], sents[i][2])) UnicodeEncodeError: 'ascii' codec can't encode character '\xdf' in position 213: ordinal not in range(128) see http://stackoverflow.com/questions/4374455/how-to-set-sys-stdout-encoding-in-python-3
-rwxr-xr-xmgizapp/scripts/merge_alignment.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/mgizapp/scripts/merge_alignment.py b/mgizapp/scripts/merge_alignment.py
index b3dc749..c018067 100755
--- a/mgizapp/scripts/merge_alignment.py
+++ b/mgizapp/scripts/merge_alignment.py
@@ -46,6 +46,8 @@ def main():
sys.stdin = codecs.getreader('UTF-8')(sys.stdin)
sys.stdout = codecs.getwriter('UTF-8')(sys.stdout)
sys.stderr = codecs.getwriter('UTF-8')(sys.stderr)
+ else:
+ sys.stdout = open(sys.stdout.fileno(), mode='w', encoding='utf8', buffering=1)
if len(sys.argv) < 2:
sys.stderr.write("Provide me the file names (at least 2)\n")