Python| TextBlob.correct() 方法
借助TextBlob.correct()方法,如果任何句子有拼写错误,我们可以使用 TextBlob.correct() 方法得到更正的单词。
Syntax : TextBlob.correct()
Return : Return the correct sentence without spelling mistakes.
示例 #1:
在这个例子中,我们可以说通过使用 TextBlob.correct() 方法,我们能够得到正确的句子而没有任何拼写错误。
Python3
# import TextBlob
from textblob import TextBlob
gfg = TextBlob("GFG is a good compny and alays value ttheir employes.")
# using TextBlob.correct() method
gfg = gfg.correct()
print(gfg)
Python3
# import TextBlob
from textblob import TextBlob
gfg = TextBlob("I amm goodd at spelling mstake.")
# using TextBlob.correct() method
gfg = gfg.correct()
print(gfg)
输出:
GFG is a good company and always value their employed.
示例 #2:
Python3
# import TextBlob
from textblob import TextBlob
gfg = TextBlob("I amm goodd at spelling mstake.")
# using TextBlob.correct() method
gfg = gfg.correct()
print(gfg)
输出 :
I am good at spelling mistake.