From a0206fd7c45da0b31501713ac65834f69745b696 Mon Sep 17 00:00:00 2001 From: "trevor.cohn" Date: Mon, 19 Jul 2010 22:40:21 +0000 Subject: Tool to pull out separate language data from context.txt.gz git-svn-id: https://ws10smt.googlecode.com/svn/trunk@326 ec762483-ff6d-05da-a07a-a48fb63a330f --- gi/posterior-regularisation/split-languages.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 gi/posterior-regularisation/split-languages.py (limited to 'gi/posterior-regularisation/split-languages.py') diff --git a/gi/posterior-regularisation/split-languages.py b/gi/posterior-regularisation/split-languages.py new file mode 100755 index 00000000..206da661 --- /dev/null +++ b/gi/posterior-regularisation/split-languages.py @@ -0,0 +1,23 @@ +#!/usr/bin/python + +import sys + +sout = open(sys.argv[1], 'w') +tout = open(sys.argv[2], 'w') +for line in sys.stdin: + phrase, contexts = line.rstrip().split('\t') + sp, tp = phrase.split(' ') + sout.write('%s\t' % sp) + tout.write('%s\t' % tp) + parts = contexts.split(' ||| ') + for i in range(0, len(parts), 2): + sc, tc = parts[i].split(' ') + if i != 0: + sout.write(' ||| ') + tout.write(' ||| ') + sout.write('%s ||| %s' % (sc, parts[i+1])) + tout.write('%s ||| %s' % (tc, parts[i+1])) + sout.write('\n') + tout.write('\n') +sout.close() +tout.close() -- cgit v1.2.3