You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: pontoon/machinery/openai_service.py
+7-7Lines changed: 7 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -22,8 +22,11 @@ def get_translation(
22
22
f"The target language '{target_language_name}' is not supported."
23
23
)
24
24
25
+
intro_text=f"Refine the {target_language_name} machine translation to make it {characteristic}."
26
+
25
27
common_rules=textwrap.dedent(
26
-
"""1) ENDING PUNCTUATION — SEMANTICS, NOT LITERAL CHAR:
28
+
"""Follow these rules IN ORDER OF PRIORITY:
29
+
1) ENDING PUNCTUATION — SEMANTICS, NOT LITERAL CHAR:
27
30
- Detect the English ending: none, ".", "?", "!", "…".
28
31
- The translation MUST express the same ending SEMANTIC:
29
32
• if English ends with "?" → translation ends with a question.
@@ -36,18 +39,16 @@ def get_translation(
36
39
)
37
40
38
41
informal=textwrap.dedent(
39
-
f"""You will be provided with text in English, along with its machine-generated translation in {target_language}.
42
+
f"""{intro_text}
40
43
Revise the {target_language} translation to use simpler language,
41
-
Follow these rules IN ORDER OF PRIORITY:
42
44
{common_rules}
43
45
3) Clarity and Simplicity: keep wording straightforward and consistent.
44
46
Output only the revised translation."""
45
47
)
46
48
47
49
formal=textwrap.dedent(
48
-
f"""You will be provided with text in English, along with its machine-generated translation in {target_language}.
50
+
f"""{intro_text}
49
51
Revise the {target_language} translation to use a higher level of formality.
50
-
Follow these rules IN ORDER OF PRIORITY:
51
52
{common_rules}
52
53
3) Consistency: maintain a consistent level of formality throughout; do not mix formal and informal modes.
53
54
4) Preserve all HTML tags and their order. Do not add, remove, or reorder tags.
@@ -56,9 +57,8 @@ def get_translation(
56
57
)
57
58
58
59
rephrased=textwrap.dedent(
59
-
f"""You will be provided with text in English, along with its machine-generated translation in {target_language}.
60
+
f"""{intro_text}
60
61
Provide an alternative translation that preserves the original meaning while varying the wording.
61
-
Follow these rules IN ORDER OF PRIORITY:
62
62
{common_rules}
63
63
3) Cultural and Idiomatic Fit: adapt idioms and culturally marked expressions appropriately for {target_language}; you may restructure sentences but must not introduce new information or omit essential meaning.
64
64
4) Clarity and Naturalness: ensure the result reads naturally and is easy to understand.
0 commit comments