自动纠正列表列表中拼写错误的单词 - python

时间:2018-01-16 08:08:41

标签: python multithreading nlp nltk text-mining

我有一个包含单词/代币的列表列表。

Eg:- [[u'note', u'subject', u'mussage', u'aar', u'install'],[ u'accomplishment', u'survice', u'hte', u'skinn', u'damaged', u'location', u'shown'] 

需要一个python脚本,它会自动更正拼写错误的单词并提供结果。

Eg:- [[u'note', u'subject', u'message', u'air', u'install'],[ u'accomplishment', u'service', u'the', u'skin', u'damaged', u'location', u'shown']

我有大约200万个列表,每个列表有超过5000个单词/令牌。如何在很短的时间内完成作业的脚本

1 个答案:

答案 0 :(得分:1)

您可以使用 autocorrect lib来完成任务。

from autocorrect import spell

k = [[u'note', u'subject', u'mussage', u'aar', u'install'],[ u'accomplishment', u'survice', u'hte', u'skinn', u'damaged', u'location', u'shown']]

res = [map(spell, l) for l in k]
print res

结果:

[[u'note', u'subject', u'message', u'Aar', u'install'], [u'accomplishment', u'service', u'the', u'skin', u'damaged', u'location', u'shown']]