Skip to content

Instantly share code, notes, and snippets.

@fiorentinogiuseppe
Created January 17, 2020 18:26
Show Gist options
  • Save fiorentinogiuseppe/c411021315978171b4154c26a5cb98fe to your computer and use it in GitHub Desktop.
Save fiorentinogiuseppe/c411021315978171b4154c26a5cb98fe to your computer and use it in GitHub Desktop.
Verifica se uma palavra está escrita corretamente e substitui-a.
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