adjadv.py 876 Bytes
#!/usr/bin/env python
#-*- coding:utf-8 -*-

import sys


def get_lines():
    first = True
    search = False
    lines = []
    for line in sys.stdin:
        if first:
            if '\tadj:' in line:
                search = True
                adj = line.split()[0]
                nie_prefix = ''
                while adj.startswith(nie_prefix):
                    nie_prefix += 'nie'
            first = False
        if search and '\tadv:pos' in line:
            if not line.startswith(nie_prefix):
                lines.append(
                    '%s %s\n' % (line.split()[0], adj))#, line.split()[2]))
            else:
                print>> sys.stderr, line.split()[0], adj
        if line == '\n':
            first = True
            search = False
    return lines


if __name__ == '__main__':
    lines = get_lines()
    sys.stdout.write(''.join(lines))