You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@joshua.apache.org by mj...@apache.org on 2017/02/01 01:28:01 UTC
[5/9] incubator-joshua git commit: bugfix in moses phrase table
conversion
bugfix in moses phrase table conversion
problem was with handling lines starting with '['
Project: http://git-wip-us.apache.org/repos/asf/incubator-joshua/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-joshua/commit/ca6e8454
Tree: http://git-wip-us.apache.org/repos/asf/incubator-joshua/tree/ca6e8454
Diff: http://git-wip-us.apache.org/repos/asf/incubator-joshua/diff/ca6e8454
Branch: refs/heads/master
Commit: ca6e8454c338e91a93df2f0b93a88e8149403c1f
Parents: e80f0a5
Author: Matt Post <po...@cs.jhu.edu>
Authored: Mon Jan 30 23:50:22 2017 -0500
Committer: Matt Post <po...@cs.jhu.edu>
Committed: Mon Jan 30 23:50:22 2017 -0500
----------------------------------------------------------------------
scripts/support/phrase2hiero.py | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/ca6e8454/scripts/support/phrase2hiero.py
----------------------------------------------------------------------
diff --git a/scripts/support/phrase2hiero.py b/scripts/support/phrase2hiero.py
index fd86f02..13ed094 100755
--- a/scripts/support/phrase2hiero.py
+++ b/scripts/support/phrase2hiero.py
@@ -41,19 +41,16 @@ def maybelog(value):
except ValueError:
return value
-for line in sys.stdin:
- moses = False
+for lineno,line in enumerate(sys.stdin):
# Moses phrase tables do not have a left-hand side symbol, add that
- if not line.startswith('['):
- line = '[X] ||| ' + line
- moses = True
+ line = '[X] ||| ' + line
# Get all the fields
tokens = line.split(r' ||| ')
# take the -log() of each input token
- if moses and len(tokens) >= 4:
+ if len(tokens) >= 4:
tokens[3] = ' '.join(map(maybelog, tokens[3].split(' ')))
print ' ||| '.join(tokens),