自动更正列表列表中拼写错误的单词 - python
auto correct misspelled words in a list of lists - python
我有一个列表列表,其中包含 words/tokens。
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 个 words/tokens。如何做一个脚本在很短的时间内完成工作
您可以使用 autocorrect 库来完成您的任务。
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']]
我有一个列表列表,其中包含 words/tokens。
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 个 words/tokens。如何做一个脚本在很短的时间内完成工作
您可以使用 autocorrect 库来完成您的任务。
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']]