Skip to content

Instantly share code, notes, and snippets.

View fiorentinogiuseppe's full-sized avatar
🐧
Working from home

Giuseppe Fiorentino Neto fiorentinogiuseppe

🐧
Working from home
View GitHub Profile
@fiorentinogiuseppe
fiorentinogiuseppe / bobp-python.md
Created April 16, 2020 18:23 — forked from sloria/bobp-python.md
A "Best of the Best Practices" (BOBP) guide to developing in Python.

The Best of the Best Practices (BOBP) Guide for Python

A "Best of the Best Practices" (BOBP) guide to developing in Python.

In General

Values

  • "Build tools for others that you want to be built for you." - Kenneth Reitz
  • "Simplicity is alway better than functionality." - Pieter Hintjens
@fiorentinogiuseppe
fiorentinogiuseppe / gist:db8f9f5276c740acf0facc7462cf2236
Created April 6, 2020 12:26 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup

People

:bowtie: :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:
@fiorentinogiuseppe
fiorentinogiuseppe / algoritmo_correcao.txt
Created January 17, 2020 19:47
Cria uma lista de correções
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
@fiorentinogiuseppe
fiorentinogiuseppe / upload_file.py
Created January 17, 2020 19:25
Realiza o upload do documento para o colabs
uploaded = files.upload()
for k in uploaded.keys():
pdf = uploaded[k]
@fiorentinogiuseppe
fiorentinogiuseppe / get_ocr_documents.py
Created January 17, 2020 18:33
Percorre as imagens do PDF `lendo-as` com o pytesseract convertendo imagem em `string`
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
@fiorentinogiuseppe
fiorentinogiuseppe / get_pages_as_images.py
Created January 17, 2020 18:32
Percorre as paginas do PDF convertendo-o em imagem e realizando a binarização
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
-------
@fiorentinogiuseppe
fiorentinogiuseppe / binarization.py
Created January 17, 2020 18:29
Função que aplica a binarização na imagem
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
@fiorentinogiuseppe
fiorentinogiuseppe / corrected.py
Created January 17, 2020 18:26
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("---------")