#!/usr/bin/env python3

import sys
import re

def isContent(pos):
     ret = re.search(r"(M|P|DT|DEG|DEC|DEV|DER|CC|CS|LC|AS|SP|MSP|LB|SB|BA)",pos)
     return ret is None


if __name__ == "__main__":
    if len(sys.argv) < 2:
        sys.exit("you must provide filename")
    
    with open(sys.argv[1],"r") as f:
        for line in f:
            line = line.rstrip()
            if line.startswith("#") or line=="":
                print(line)
                continue
            tokens = list(map(lambda x: int(x) if re.search(r'^(\d)*$', x) else x, line.split("\t")))
            # tokens = list(map(lambda x: int(x) if x.isdigit() else x, line.split("\t")))
            id = tokens[0] - 1
            surface = tokens[1]
            pos = tokens[3]
            dep_id = tokens[6] - 1
            isCont = isContent(pos)
            if pos == "PU":
                isCont = "-1"
            elif isCont:
                isCont = "1"
            else:
                isCont = "0"
            print("%d\t%d\t%s\t%s\t%s\t%s\t%s\t_\t_" % (id, dep_id, surface, surface, pos, isCont, pos))
