Skip to content

Commit

Permalink
长文翻译的Prompt英文翻译
Browse files Browse the repository at this point in the history
Former-commit-id: 135d310
  • Loading branch information
FunnySaltyFish committed Dec 16, 2023
1 parent 1f24e6b commit 5e0273e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ object TextSplitter {
for(puncs in hierarchyPunctuations) {
val idx = text.rfind(puncs, 0, text.length - 1)
if (idx != -1) {
// 由于大多数情况下,这个分隔符是换行符,所以这里直接返回 idx,换行符留给下一次作为输入,尽量保持格式
return text.substring(0, idx)
return text.substring(0, idx + 1)
}
}
return text
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,8 @@ import org.json.JSONObject
import java.util.UUID


const val DEFAULT_PROMPT_PREFIX = """你现在是一名优秀的翻译人员,现在在翻译长文中的某个片段。请根据给定的术语表,将输入文本翻译成中文"""
const val DEFAULT_PROMPT_SUFFIX = """,并找出可能存在的新术语。你的输出分为两部分,以||sep||分割,前半部分是翻译结果,后半部分是关键词,以JSON数组的形式,无则为[]
示例输入:XiaoHong and XiaoMing are studying DB class.||sep||[["DB","数据库"],["XiaoHong","萧红"]]
示例输出:萧红和晓明正在学习数据库课程||sep||[["XiaoMing","晓明"]]
保持译文和原文格式一致,正确输出换行"""
val DEFAULT_PROMPT_PREFIX = string(R.string.default_long_text_trans_prompt_prefix)
val DEFAULT_PROMPT_SUFFIX = string(R.string.default_long_text_prompt_suffix)

private val DEFAULT_PROMPT = EditablePrompt(DEFAULT_PROMPT_PREFIX, DEFAULT_PROMPT_SUFFIX)

Expand Down
2 changes: 2 additions & 0 deletions translate/src/main/res/values-en/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -328,4 +328,6 @@
<string name="unparseable_prompt">Unparseable error output:</string>
<string name="chat_prompt_help">Prompt specifies the task of the model, which can greatly affect the quality of translation. If there are special requirements (such as language, expression, professional field, etc.), it is recommended to specify,\n\nIt must be related to foreign language learning and translation, and judgment will be made during modification. Whether the judgment passes or not, the points used for judgment will be deducted. Please modify it carefully</string>
<string name="app_light_dark_mode">Dark Mode</string>
<string name="default_long_text_trans_prompt_prefix">You are now an excellent translator, working on translating a fragment of a long text. Please translate the input text into English according to the given terminology list.</string>
<string name="default_long_text_prompt_suffix">Also, identify any potential new terminology. Your output consists of two parts, separated by ||sep||. The first part is the translation result, and the second part is the keywords in the form of a JSON array. If there are no keywords, it should be [].\nExample input: XiaoHong and XiaoMing are studying DB class.||sep||[[\"DB\",\"数据库\"],[\"XiaoHong\",\"萧红\"]]\nExample output: 萧红和晓明正在学习数据库课程||sep||[[\"XiaoMing\",\"晓明\"]]\n\nPlease maintain the format of the translated text consistent with the original text and correctly output all line breaks.</string>
</resources>
2 changes: 2 additions & 0 deletions translate/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -328,4 +328,6 @@
<string name="unparseable_prompt">无法解析的错误输出:</string>
<string name="chat_prompt_help">Prompt指定了模型的任务,它能很大程度上影响翻译质量。如果有特殊的需求(比如语种、表达方式、专业领域等),建议指定、\n\n必须和外语类学习、翻译相关,修改时会进行判定。无论判定是否通过,均会扣除判定所用的点数,谨慎修改</string>
<string name="app_light_dark_mode">深色模式</string>
<string name="default_long_text_trans_prompt_prefix">你现在是一名优秀的翻译人员,现在在翻译长文中的某个片段。请根据给定的术语表,将输入文本翻译成中文</string>
<string name="default_long_text_prompt_suffix">,并找出可能存在的新术语。你的输出分为两部分,以||sep||分割,前半部分是翻译结果,后半部分是关键词,以JSON数组的形式,无则为[]\n示例输入:XiaoHong and XiaoMing are studying DB class.||sep||[[\"DB\",\"数据库\"],[\"XiaoHong\",\"萧红\"]]\n示例输出:萧红和晓明正在学习数据库课程||sep||[[\"XiaoMing\",\"晓明\"]]\n\n保持译文和原文格式一致,正确输出换行</string>
</resources>

0 comments on commit 5e0273e

Please sign in to comment.