Пример #1
0
#-*- coding:utf-8 -*-
from knock40 import mkMorphclass
from knock41 import mkChunkclass

s = ""
t = ""
for line in mkChunkclass(mkMorphclass()):
    for phrase in line:
        d = int(phrase.dst)
        for word in phrase.morph:
            if word.pos != "記号":
                s += word.surface
        for word in line[d].morph:
            if word.pos != "記号":
                t += word.surface
        print(s + "\t" + t)
        s = ""
        t = ""
Пример #2
0
    s=""
    t=""
    for item in line[n].morph:
        if item.pos=="名詞":
            s+="X"
        else:
            s+=item.surface
    for item in line[m].morph:
        if item.pos=="名詞":
            t+="Y"
        else:
            t+=item.surface
    return ([s,t])

test=0
for line in mkChunkclass(mkMorphclass()):
    test+=1
    for i in range(len(line)):
        c=0
        for item in line[i].morph:
            if item.pos=="名詞":
              c+=1
        if line[i].dst!="-1" and c>=1:
            for j in range(i+1,len(line)):
                for item in line[j].morph:
                    if item.pos=="名詞":
                        if len(mkpass(line,int(line[i].dst),j).split("|"))<=2:
                            print(mk_i_j(line,i,j)[0]+mkpass(line,int(line[i].dst),j).split("|")[0]+" -> "+mk_i_j(line,i,j)[1])
                        else:
                            print(mk_i_j(line,i,j)[0]+mkpass(line,int(line[i].dst),j).split("|")[0]+"|"+mk_i_j(line,i,j)[1]+mkpass(line,int(line[i].dst),j).split("|")[1]+"|"+mkpass(line,int(line[i].dst),j).split("|")[2])
#    if test==8: