我有非常大的数字和字母数字集的集合,我想用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或我需要写一个?我可以用蛮力做到这一点,但在我的一些大型文件中这可能需要几年时间。我'假设'这是一个普遍的问题,一些聪明的饼干找到了解决方案。希望这不是一个旅行推销员。
你在寻找unigram,bigram,trigram等数字吗? – Gingerbread
我不得不承认,我不知道你的意思是unigram,bigram,trigram ...但是快速查找我想到了单词级别bigram/trigram/etc ..匹配。任何匹配集我认为4字匹配将是我想要处理的最大集。 – JustBroken