# -*- coding: utf-8 -*-
import re

class Morph(object):
    def __init__(self, surface, base, pos, pos1):
        # メンバ変数
        self.surface = surface
        self.base = base
        self.pos = pos
        self.pos1 = pos1

    def output(self):
        return self.surface + "\t" + \
               self.base + ", " + \
               self.pos + ", " + \
               self.pos1

def make_morphs(filename):
    morph, morphs = [], []
    f = open(filename, 'r')
    for line in f.readlines():
        line = line.strip()
        if line == "EOS":
            morphs.append(morph)
            morph = []
        elif line[0] == "*":
            continue 
        else:
            mo = get_morph(line) 
            morph.append(mo)
    f.close()
    return morphs

def get_morph(line):
    surface = line.split('\t')[0]
    base = line.split('\t')[1].split(',')[6]
    pos = line.split('\t')[1].split(',')[0]
    pos1 = line.split('\t')[1].split(',')[1]
    morph = Morph(surface, base, pos, pos1)
    return morph

if __name__ == '__main__':
    morphs = make_morphs('neko.txt.cabocha')
    for m in morphs[2]:
        print m.output()
