summaryrefslogtreecommitdiff
path: root/gi/posterior-regularisation/split-languages.py
blob: 206da661c3c353967f70db920f7f6fe024d30150 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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(' <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(' <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()