thisからtext1.similar( "monstrous")とtext1.concordance( "monstrous")を読みました。nltkのsimilar()とconcordanceの相違点
ここでは、Pythonの自然言語処理ツールキットのtext1.concordance('monstrous')
とtext1.similar('monstrous')
の違いについて満足のいく答えを得ることができませんでした。
例を詳しく説明してください。
thisからtext1.similar( "monstrous")とtext1.concordance( "monstrous")を読みました。nltkのsimilar()とconcordanceの相違点
ここでは、Pythonの自然言語処理ツールキットのtext1.concordance('monstrous')
とtext1.similar('monstrous')
の違いについて満足のいく答えを得ることができませんでした。
例を詳しく説明してください。
concordance(token)
を使用すると、引数token
を囲むコンテキストが得られます。文章はtoken
と表示されます。 similar(token)
を使用して
はtoken
と同じ文脈で出現する単語のリストを返します。この場合、文脈はちょうどtoken
のどちらかの側の言葉です。
だから、Moby Dickのテキスト(text1
)を見てください。私たちは、'monstrous'
text1.concordance('monstrous')
# returns:
Displaying 11 of 11 matches:
ong the former , one was of a most monstrous size . ... This came towards us ,
ON OF THE PSALMS . " Touching that monstrous bulk of the whale or ork we have r
ll over with a heathenish array of monstrous clubs and spears . Some were thick
d as you gazed , and wondered what monstrous cannibal and savage could ever hav
that has survived the flood ; most monstrous and most mountainous ! That Himmal
they might scout at Moby Dick as a monstrous fable , or still worse and more de
th of Radney .'" CHAPTER 55 Of the Monstrous Pictures of Whales . I shall ere l
ing Scenes . In connexion with the monstrous pictures of whales , I am strongly
ere to enter upon those still more monstrous stories of them which are to be fo
ght have been rummaged out of this monstrous cabinet there is no telling . But
of Whale - Bones ; for Whales of a monstrous size are oftentimes cast up dead u
の一致を確認することができますそして、我々は'monstrous'
と同様の文脈で出現する単語のリストを取得することができます。最初に返される行のコンテキストは'most _____ size'
です。
text1.similar('monstrous')
# returns:
determined maddens contemptible modifies abundant tyrannical puzzled
trustworthy impalpable gamesome curious mean pitiable untoward
christian subtly passing domineering uncommon true
私たちは言葉'true'
を取ると、それは我々が単語「true
」の最初の25 87の使用を取り戻すだろうtext.concordance('true')
との一致です確認してください。これは非常に有用ではありませんが、NLTKでは、単語リストの使用が同じ周囲の単語をいつ使用するかを示すcommon_contexts
という追加の方法を提供しています。
text1.common_contexts(['monstrous', 'true'])
# returns:
the_pictures
この結果は、フレーズ"the monstrous pictures"
と"the true pictures"
両方が白鯨に表示されていることを教えてくれる。
あなたの優れた説明をありがとうございます。しかし、私は同様のことについて完全にはっきりしていませんので、試してみてください。 @ジェームス – dex