Skip to content

feat: 增强 CJK 歌词语言处理逻辑 - #240

Open
MoYingJi wants to merge 1 commit into
SPlayer-Dev:devfrom
MoYingJi:pr/feat/lang
Open

feat: 增强 CJK 歌词语言处理逻辑#240
MoYingJi wants to merge 1 commit into
SPlayer-Dev:devfrom
MoYingJi:pr/feat/lang

Conversation

@MoYingJi

@MoYingJi MoYingJi commented Sep 6, 2026

Copy link
Copy Markdown
Collaborator

改动类型

  • 新功能(feat)
  • 缺陷修复(fix)
  • 重构 / 优化(不改变对外行为)
  • 文档(docs)
  • 其他(请在「改动说明」中注明)

是否包含破坏性变更

  • 是(请在「改动说明」中详细描述)

改动说明

原先的根据翻译的启发式判断还是会误判某些情况,比如由 kid141252010 反馈的 《等你的回答》,这首歌仅有开头的制作人有谚文,但却被整首歌判为韩语

此 PR 增加了判断包含假名或谚文的行与包含汉字的行的比值是否超过阈值判断 CJK 的主语言,避免了这种情况下的误判。除此之外,也将 ruby 内容也算作歌词内容的一部分,以考虑纯汉字行但 ruby 为假名的情况

比例的阈值 THRESHOLD = 0.37 是我根据 《人是猫》12 / 33 ≈ 0.3636363636 猜的,是否适用于所有情况还未知

自查清单

  • 本 PR 只包含一个主要功能 / 修复,没有夹带无关改动
  • 已在本地完整测试通过;AI 生成的代码同样自行测试并审阅过,未做未经验证的提交
  • 已运行 pnpm format,并确认 pnpm typecheckpnpm lint 通过
  • 改动涉及原生模块时已 pnpm build:native 验证;未手写 native/*/index.d.ts
  • 已向 dev 分支提交

pnpm format 无法通过。但这与此 PR 无关

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

新增逻辑中存在可导致 TypeScript 编译错误与 ruby 文本未被正确纳入检测的明确 bug,需要先修复后再合入。

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

本 PR 旨在改进歌词行语言标注(LyricLine.language)的 CJK 语言推断逻辑,通过引入「假名/谚文行数占比阈值」与「翻译启发式」来降低误判,并计划把 ruby 注音也纳入检测文本以覆盖更多边界情况。

Changes:

  • 新增基于 kanaLineCount / hanLineCounthangulLineCount / hanLineCount 的比例阈值推断主 CJK 语言(THRESHOLD = 0.37)。
  • 保留并调整“全假名/全谚文行均有翻译”启发式,用于区分双语混合歌词中的纯汉字行。
  • 将 ruby 内容合并到行文本中参与脚本检测(当前实现存在类型拼接问题,需要修复)。
File summaries
File Description
src/utils/lyric/language.ts 调整歌词行语言推断:引入比例阈值与 ruby 参与检测,并重构纯汉字行的语言判定逻辑
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/utils/lyric/language.ts Outdated
Comment thread src/utils/lyric/language.ts
@MoYingJi
MoYingJi marked this pull request as ready for review September 6, 2026 01:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants