核心功能 - 拼写修正

这个很棒的脚本将帮助你纠正你的文本单词拼写错误。你可以在下面找到脚本,将告诉你如何修复句子中的单个单词或多个单词。

实现代码

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45


# Spell Fixer


# pip install textblob


from textblob import *


# Fixing Paragraph Spells


def fix_paragraph_words(paragraph):


    sentence = TextBlob(paragraph)


    correction = sentence.correct()


    print(correction)


# Fixing Words Spells


def fix_word_spell(word):


    word = Word(word)


    correction = word.correct()


    print(correction)


fix_paragraph_words("This is sammple tet!!")


fix_word_spell("maangoo")