|
|
|
@@ -271,6 +271,24 @@ def create_pdf_from_results(results, output_path): |
|
|
|
doc.build(story) |
|
|
|
print(f"PDF généré avec succès : {output_path}") |
|
|
|
|
|
|
|
def create_txt_from_results(results, output_path): |
|
|
|
"""Crée un fichier TXT à partir des résultats de traduction.""" |
|
|
|
OUTPUT_TXT_PATH = output_path.replace(".pdf", f".txt") # Chemin du fichier TXT de sortie |
|
|
|
|
|
|
|
# Titre avec la langue cible |
|
|
|
title_text = f"Traduction - Ukrainien vers {TARGET_LANGUAGE.capitalize()}" |
|
|
|
with open(OUTPUT_TXT_PATH, 'w', encoding='utf-8') as txt_file: |
|
|
|
txt_file.write(title_text + "\n\n") |
|
|
|
|
|
|
|
# Contenu |
|
|
|
for page_num, translation in results.items(): |
|
|
|
# Préserver la mise en page en convertissant les sauts de ligne |
|
|
|
txt_file.write(translation + "\n\n") |
|
|
|
|
|
|
|
# Infos sur le LLM |
|
|
|
txt_file.write("\n") |
|
|
|
txt_file.write(display_llm_info() + "\n") |
|
|
|
|
|
|
|
def main(): |
|
|
|
# Affiche les informations du modèle LLM |
|
|
|
display_llm_info() |
|
|
|
@@ -299,6 +317,7 @@ def main(): |
|
|
|
|
|
|
|
# Création du PDF avec tous les résultats |
|
|
|
create_pdf_from_results(results, OUTPUT_PDF_PATH) |
|
|
|
create_txt_from_results(results, OUTPUT_PDF_PATH) |
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
|
main() |