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

def make_sen_data(n):
    sen_data = {}
    chunks = q41.make_chunks('neko.txt.cabocha')
    for i, ch in enumerate(chunks[n]):
        ans_dict = ch.make_ans_dict()
        sen_data[i] = {
          "morphs":ans_dict['morphs'].replace(' ', ''), 
          "pos":ans_dict['pos'], 
          "dst":ans_dict['dst']
        }
    return sen_data

def make_route_list(sen_data):
    target_pos = '名詞'
    route_list = []
    for k, v in sen_data.items():
        if target_pos not in v['pos'] or int(v['dst']) == -1:
            continue
        tmp = []
        tmp.append(v['morphs'])
        n = int(v['dst'])
        while n != -1:
            tmp.append(sen_data[n]['morphs'])
            n = int(sen_data[n]['dst'])
        route_list.append('->'.join(tmp))
    return route_list

def main(num):
    sen_data = make_sen_data(num)
    route_list = make_route_list(sen_data)
    return route_list

if __name__ == '__main__':
    for r in main(5):
        print r
