summaryrefslogtreecommitdiff
path: root/sa-extract/sa2cdec.py
diff options
context:
space:
mode:
authorPatrick Simianer <simianer@cl.uni-heidelberg.de>2012-05-31 13:57:24 +0200
committerPatrick Simianer <simianer@cl.uni-heidelberg.de>2012-05-31 13:57:24 +0200
commitf1ba05780db1705493d9afb562332498b93d26f1 (patch)
treefb429a657ba97f33e8140742de9bc74d9fc88e75 /sa-extract/sa2cdec.py
parentaadabfdf37dfd451485277cb77fad02f77b361c6 (diff)
parent317d650f6cb1e24ac6f3be6f7bf9d4246a59e0e5 (diff)
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'sa-extract/sa2cdec.py')
-rwxr-xr-xsa-extract/sa2cdec.py19
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) )