短语/多字以及跨大数据集的计数匹配

时间:2017-07-17 17:00:58

标签: algorithm python-2.7

我有非常大量的数字和字母数字集合,我希望用python 2.7在其中找到常用的单词/短语。

示例数据,与我的真实数据无关,但这可以很好地代表它。

'this is a test of the hosting',
'test is a test',
'we have more tests to run before we can trust it',
'if it true,  can trust it',
'tom is on time for ounce',
'what do you mean tom is out sick again'

我正在寻找以下类型的匹配

'is' x 5
'test' x 3
'is a test' x 2
'is a' x2
'we' x2
'trust it' x 2
'tom' x 2
..etc..

是否有一个共同的lib或我需要写一个?我可以用蛮力做到这一点,但是对于我的一些较大的文件,这可能需要数年时间。我假设'这是一个常见问题,一些智能cookie已经找到了解决方案。希望这不是一个旅行推销员。

1 个答案:

答案 0 :(得分:0)

我认为你正在寻找unigram,bigram,trigram计数。您可以在Python中使用NLTK库来执行您想要的操作。

另外,请检查此link

相关问题