Created
January 17, 2020 18:26
-
-
Save fiorentinogiuseppe/c411021315978171b4154c26a5cb98fe to your computer and use it in GitHub Desktop.
Verifica se uma palavra está escrita corretamente e substitui-a.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
corrected = [] | |
for i in splited_words: #splited_words é o texto limpo e dividido em tokens | |
if not natas.is_correctly_spelled(i) and not is_number(i) and i: | |
try: | |
sug = natas.ocr_correct_words([i], n_best = 20)[0] | |
except: | |
sug = natas.ocr_correct_words([i], n_best = 10)[0] | |
print("Palavra errada: ", i) | |
print("Sugestão: ",sug) | |
print("---------") | |
if sug: | |
corrected.append(sug[0]) | |
else: | |
corrected.append(i) | |
elif i: | |
corrected.append(i) | |
print(corrected) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment