génération d'un fichier texte
This commit is contained in:
parent
3a40d79f31
commit
c28bbc6be7
12
Modelfile
12
Modelfile
|
|
@ -1,10 +1,10 @@
|
||||||
FROM zongwei/gemma3-translator:4b
|
FROM zongwei/gemma3-translator:4b
|
||||||
PARAMETER temperature 0.1
|
PARAMETER temperature 0.3
|
||||||
PARAMETER num_ctx 131072
|
PARAMETER num_ctx 131072
|
||||||
SYSTEM """
|
SYSTEM """
|
||||||
You are a professional translator specialising in translating Ukrainian text into English.
|
Tu es un traducteur professionnel spécialisé dans la traduction de textes historiques ukrainiens.
|
||||||
Translate accurately and naturally, respecting the original intonation used by the author of the text.
|
Traduis avec précision et naturel, en respectant l'intonation originale utilisée par l'auteur du texte.
|
||||||
You must always answer in french.
|
Tu dois toujours répondre en français.
|
||||||
You must not interpret the author's thoughts or reflections.
|
Tu ne dois pas interpréter les pensées ou les réflexions de l'auteur.
|
||||||
Do not add any text before or after the text provided.
|
N'ajoutes aucun texte sous quelle forme que ce soit avant ou après le texte tarduit.
|
||||||
"""
|
"""
|
||||||
19
main.py
19
main.py
|
|
@ -271,6 +271,24 @@ def create_pdf_from_results(results, output_path):
|
||||||
doc.build(story)
|
doc.build(story)
|
||||||
print(f"PDF généré avec succès : {output_path}")
|
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():
|
def main():
|
||||||
# Affiche les informations du modèle LLM
|
# Affiche les informations du modèle LLM
|
||||||
display_llm_info()
|
display_llm_info()
|
||||||
|
|
@ -299,6 +317,7 @@ def main():
|
||||||
|
|
||||||
# Création du PDF avec tous les résultats
|
# Création du PDF avec tous les résultats
|
||||||
create_pdf_from_results(results, OUTPUT_PDF_PATH)
|
create_pdf_from_results(results, OUTPUT_PDF_PATH)
|
||||||
|
create_txt_from_results(results, OUTPUT_PDF_PATH)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue