Repository navigation
feat: 增强歌词语言识别逻辑以支持中日混合歌词 - #121
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
增强歌词语言识别,通过翻译信息区分中日/中韩混合歌词中的纯汉字行。
Changes:
- 新增翻译存在性检查及混合语言推断。
- 补充中日混合歌词测试。
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/utils/lyric/language.ts |
扩展 CJK 歌词语言推断逻辑。 |
src/utils/lyric/language.test.ts |
新增翻译推断测试。 |
Comments suppressed due to low confidence (1)
src/utils/lyric/language.ts:68
- 这里同时新增了“所有谚文行均有翻译时,将无翻译纯汉字行判为中文”的分支,但新增测试只覆盖了假名路径;目前即使韩语分支条件或结果写错也不会被发现。请补一个包含已翻译谚文行和无翻译汉字行的对称用例。
} else if (hasHangul) {
line.language = allHangulTranslated && !isTranslated ? "zh-CN" : "ko";
Comment on lines
+60
to
+68
| if (KANA_RE.test(content)) { | ||
| line.language = "ja"; | ||
| } else if (HANGUL_RE.test(content)) { | ||
| line.language = "ko"; | ||
| } else if (HAN_RE.test(content)) { | ||
| if (hasKana) { | ||
| line.language = allKanaTranslated && !isTranslated ? "zh-CN" : "ja"; | ||
| } else if (hasHangul) { | ||
| line.language = allHangulTranslated && !isTranslated ? "zh-CN" : "ko"; |
Collaborator
Author
There was a problem hiding this comment.
原有行为,在 if (HAN_RE.test(content)) { 分支,就已经指定为全局判断的 hanLanguage 了。我这里也是同一条分支,我只是将这个 hanLanguage 优化了而已
Comment on lines
+29
to
+30
| it("通过翻译推断双语混合歌曲的纯汉字行", () => { | ||
| const lines = [createLine("爱"), createLine("君が好き", { translatedLyric: "我喜欢你" })]; |
Collaborator
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

改动类型
是否包含破坏性变更
改动说明
优化
applyLyricLanguages,增加判断,若所有有假名的行都有翻译,那么可以认定全为汉字且无翻译的行是中文代码由 AI 生成,已由人工审核
测试情况
已补充测试,测试通过
自查清单
pnpm format,并确认pnpm typecheck、pnpm lint通过pnpm build:native验证;未手写native/*/index.d.tsdev分支提交