A "Best of the Best Practices" (BOBP) guide to developing in Python.
- "Build tools for others that you want to be built for you." - Kenneth Reitz
- "Simplicity is alway better than functionality." - Pieter Hintjens
People
:bowtie: |
😄 :smile: |
😆 :laughing: |
|---|---|---|
😊 :blush: |
😃 :smiley: |
:relaxed: |
😏 :smirk: |
😍 :heart_eyes: |
😘 :kissing_heart: |
😚 :kissing_closed_eyes: |
😳 :flushed: |
😌 :relieved: |
😆 :satisfied: |
😁 :grin: |
😉 :wink: |
😜 :stuck_out_tongue_winking_eye: |
😝 :stuck_out_tongue_closed_eyes: |
😀 :grinning: |
😗 :kissing: |
😙 :kissing_smiling_eyes: |
😛 :stuck_out_tongue: |
| Percorre os tokens token_lists: | |
| Se não estiver no dicionário e não for um número: | |
| Tenta: | |
| Encontrar as 20 melhores correções | |
| Caso erro: | |
| Encontrar as 10 melhores correções | |
| Se a lista de sugestão não estiver vazia: | |
| Adiciona a primeira sugestão em correções | |
| Caso contrario: | |
| Adiciona o token que esta sendo analisado nas correcoes |
| uploaded = files.upload() | |
| for k in uploaded.keys(): | |
| pdf = uploaded[k] |
| def get_ocr_documents(images): | |
| """ | |
| Percorre as imagens do PDF `lendo-as` com o pytesseract convertendo | |
| imagem em `string`. | |
| Parameters | |
| ---------- | |
| images : PIL.Image.Image | |
| Imagens, resultados da conversão do PDF. | |
| Returns |
| def get_pages_as_images(file): | |
| """ | |
| Percorre as paginas do PDF convertendo-o em imagem e realizando a binarização | |
| Parameters | |
| ---------- | |
| file : bytes | |
| Documento em `bytes` contendo o `PDF`. | |
| Returns | |
| ------- |
| def binarization(image): | |
| """ | |
| Função que aplica a binarização na imagem. | |
| Parameters | |
| ---------- | |
| image : PIL.Image.Image | |
| Imagem para ser binarizada. | |
| Returns | |
| ------- | |
| PIL.Image.Image |
| 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("---------") |