Skip to content

Commit

Permalink
Merge pull request #80 from tmu-nlp/mio
Browse files Browse the repository at this point in the history
knock42 modified
  • Loading branch information
m-ohashii authored May 27, 2024
2 parents cf915b8 + a3742ac commit bb8291a
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions mio/chapter05/knock42.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,25 @@


for sentence in knock41.sentences:
for chunk in sentence.chunks: #sentence.chunksリストに含まれる各Chunkのインスタンスを順に取り出す
if chunk.dst != -1: #文中の文節が係り先をもつなら
#modifier = [] #係り元
#modifee = [] #係り先
modifier= ""
modifee = ""

#sentence.chunksリストに含まれる各Chunkクラスのインスタンスを取り出す
for chunk in sentence.chunks:
#文中の文節が係り先をもつなら
if chunk.dst != -1:
modifier= "" #係り元 #modifier = []
modifee = "" #係り先 #modifee = []

#係り元の文節の形態素のうち、記号以外の表層形を連結
for morph in chunk.morphs:
if morph.pos != "記号":
modifier +=morph.surface
#modifier.append(morph.surface)
modifier +=morph.surface #modifier.append(morph.surface)


#係り先の文節の形態素のうち、記号以外の表層形を連結
for morph in sentence.chunks[chunk.dst].morphs:
if morph.pos != "記号":
modifee +=morph.surface
#modifee.append(morph.surface)

print(modifier+"\t"+modifee+"\n")
#print("".join(modifier)+"\t"+"".join(modifee))
modifee +=morph.surface #modifee.append(morph.surface)

#係り元の文節と係り先の文節をタブ区切りで出力 #形態素に対する全ての処理の後に一気に文字列を作成
print(modifier+"\t"+modifee+"\n") #print("".join(modifier)+"\t"+"".join(modifee))

0 comments on commit bb8291a

Please sign in to comment.