ryanhex53 / gpt-po

command tool for translate po files by using openai api
71 stars 13 forks source link

Troubles with specific word "draft" #5

Closed fkneist closed 7 months ago

fkneist commented 1 year ago

Hi there, really useful project!

I did a couple of experiments and until now I only discovered one issue: GPT "thinks" it should create a draft instead of only translating the word.

this is the command I used:

gpt-po translate --po django.po --source german --lang english --verbose

content of django.po:

# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-10-24 20:24+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: gpt-po v1.0.10\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: German\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

#: launcher/models.py:154
msgid "draft"
msgstr ""

and this is the output:

# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
# 
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-10-24 20:24+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: gpt-po v1.0.10\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: German\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

#: launcher/models.py:154
msgid "draft"
msgstr ""
"Dear Sir/Madam,\n"
"\n"
"I hope this email finds you well. I am writing to provide you with a draft of the translation you requested. Please "
"find the translated text below:\n"
"\n"
"\"Sehr geehrte Damen und Herren,\n"
"\n"
"ich hoffe, diese E-Mail erreicht Sie in bester Verfassung. Ich schreibe Ihnen, um Ihnen einen Entwurf der von Ihnen "
"angeforderten Übersetzung zur Verfügung zu stellen. Bitte finden Sie den übersetzten Text unten:\n"
"\n"
"[Translated text]\n"
"\n"
"I hope this translation meets your expectations. If you have any further questions or require any revisions, please do "
"not hesitate to contact me. I am at your disposal to assist you with any additional language needs.\n"
"\n"
"Thank you for considering my services. I look forward to hearing from you soon.\n"
"\n"
"Best regards,\n"
"[Your Name]\""

The expected output would have been the translation of the word "draft" (German: "Entwurf")

ryanhex53 commented 1 year ago

Emm.. It seems the system prompt does not guide the bot very well. Can you share an API_KEY here and I'll try to adjust the prompt a little bit, and then you revoke the KEY after that.

ryanhex53 commented 1 year ago

Or you can add the word draft to your dictionary.json like this:

{
  "draft": "Entwurf"
}
ryanhex53 commented 1 year ago

Try the new version 1.0.11 I just updated, I have improved the prompt a little bit, maybe this problem has been resolved.

ryanhex53 commented 7 months ago

Adding more words to the dictionary.json file can improve the results of the translation model.