diff options
author | Patrick Simianer <simianer@cl.uni-heidelberg.de> | 2012-05-31 13:57:24 +0200 |
---|---|---|
committer | Patrick Simianer <simianer@cl.uni-heidelberg.de> | 2012-05-31 13:57:24 +0200 |
commit | 6f6601111710aa67eee5169e5b7d89102cc33bb8 (patch) | |
tree | 0872544abd6bc76162f3f80eb3920999afbf2c34 /sa-extract/sa2cdec.py | |
parent | 8cee8b565a9c56a7732365e9563f52ff3c4ff7fd (diff) | |
parent | 090a64e73f94a6a35e5364a9d416dcf75c0a2938 (diff) |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'sa-extract/sa2cdec.py')
-rwxr-xr-x | sa-extract/sa2cdec.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/sa-extract/sa2cdec.py b/sa-extract/sa2cdec.py new file mode 100755 index 00000000..55fb19f3 --- /dev/null +++ b/sa-extract/sa2cdec.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python +import sys + +featNames = [ line.strip() for line in open(sys.argv[1]) if not line.startswith('#') ] + +for line in sys.stdin: + try: + (lhs, src, tgt, feats, align) = line.strip("\n").split(' ||| ') + except: + print >>sys.stderr, 'WARNING: No alignments:', line + try: + (lhs, src, tgt, feats) = line.strip().split(' ||| ') + align = '' + except: + print >>sys.stderr, "ERROR: Malformed line:", line + raise + featValues = feats.split(' ') + namedFeats = ' '.join( name+"="+value for (name, value) in zip(featNames, featValues) ) + print " ||| ".join( (lhs, src, tgt, namedFeats, align) ) |