nltk中like()和concordance之间的区别 [英] difference between similar() and concordance in nltk

查看:80
本文介绍了nltk中like()和concordance之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经从对于python中自然语言处理工具包的text1.concordance('monstrous')text1.similar('monstrous')之间的区别,我无法获得满意的答案.

Where I couldn't get the satisfactory answer for the difference between text1.concordance('monstrous') and text1.similar('monstrous') of natural language processing toolkit in python.

那么,请您详细举例说明一下吧?

So would you please give the explanation with an example in detail?

推荐答案

使用concordance(token)为您提供围绕参数token的上下文.它将显示token出现的句子.

Using concordance(token) gives you the context surrounding the argument token. It will show you the sentences where token appears.

使用similar(token)返回在与token相同的上下文中出现的单词列表.在这种情况下,上下文就是直接在token两侧的单词.

Using similar(token) returns a list of words that appear in the same context as token. In this case the the context is just the words directly on either side of token.

因此,请查看Moby Dick文本(text1).我们可以检查'monstrous'

So, looking at the Moby Dick text (text1). We can check the concordance of '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'.

And then we can get a list of words that appear in similar contexts to 'monstrous'. The context for the first returned line is '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'并检查它是否与text.concordance('true')一致,我们将取回单词'true'在87个用法中的前25个.这并不是非常有用,但是NLTK确实提供了另一种称为common_contexts的方法,该方法显示何时使用一系列单词共享相同的周围单词.

If we take the word 'true' and check it's concordance with text.concordance('true') we will get back the first 25 of 87 uses of the word 'true'. This isn't terribly useful, but NLTK does provide an additional method called common_contexts that shows when the use of a list of words share the same surrounding words.

text1.common_contexts(['monstrous', 'true'])

# returns:
the_pictures

此结果告诉我们,短语"the monstrous pictures""the true pictures"都出现在Moby Dick中.

This result tells us that the phrases "the monstrous pictures" and "the true pictures" both appear in Moby Dick.

这篇关于nltk中like()和concordance之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆