summaryrefslogtreecommitdiff
path: root/python/tests/extractor/refmt.py
blob: 437d5b7a20ce44c03f3d4a4f70ef524faf474a1a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env python

import collections, sys

lines = []
f = collections.defaultdict(int)
fe = collections.defaultdict(lambda: collections.defaultdict(int))

for line in sys.stdin:
    tok = [x.strip() for x in line.split('|||')]
    count = int(tok[4])
    f[tok[1]] += count
    fe[tok[1]][tok[2]] += count
    lines.append(tok)

for tok in lines:
    feat = 'IsSingletonF={0}.0 IsSingletonFE={1}.0'.format(
        0 if f[tok[1]] > 1 else 1,
        0 if fe[tok[1]][tok[2]] > 1 else 1)
    print ' ||| '.join((tok[0], tok[1], tok[2], feat, tok[3]))