From 35458884be996125b0881287e57537f7c7046473 Mon Sep 17 00:00:00 2001 From: Tr3you <61669726+Tr3you@users.noreply.github.com> Date: Sat, 21 Aug 2021 17:53:12 -0500 Subject: [PATCH] Update processing.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Se aƱadio nueva funcion get_normalizad_text --- processing.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/processing.py b/processing.py index 464ac71..9a12666 100644 --- a/processing.py +++ b/processing.py @@ -85,4 +85,30 @@ def get_URL_Tittle(text: str): except Exception as e : print('Error delete_special_patterns: {0}'.format(e)) return result + + @staticmethod + def get_normalized_text(folder_path: str, file_name: str) -> str: + """Extrae el texto de un archivo de texto plano y lo normaliza + + Parameters + ---------- + ruta_carpeta : str + string con la ruta de la carpeta donde se encuentre el archivo a normalizar + nombre_archivo : str + nombre del archivo que desea normalizar + + Returns + ------- + posicion 1 : str + texto normalizado con encoding utf-8 + """ + text = '' + try: + with open(f'{folder_path}/{file_name}', 'r', encoding='latin1') as file: + text = file.read() + text = self.proper_encoding(text) + return text + except Exception as e: + print(f'Error: {e}') +