Skip to content

Reformat config JSON and align s2twp conversion chain - #1286

Merged
frankslin merged 1 commit into
BYVoid:masterfrom
frankslin:update-config-styling
Jun 7, 2026
Merged

frankslin merged 1 commit into
BYVoid:masterfrom
frankslin:update-config-styling

Conversation

@frankslin

Copy link
Copy Markdown
Collaborator

Format all data/config JSON files in a more readable compact style.

Change s2twp so TWPhrases participates in the same grouped conversion stage as TWVariantsPhrases and TWVariants. This means a TWPhrases match is treated as the final phrase conversion for that span instead of continuing through the later Taiwan variant stage, making the forward chain symmetric with the reverse tw2sp chain.

Verified with: bazel test //data/config:config_dict_validation_test; bazel test //test:command_line_converter_test.

@frankslin
frankslin force-pushed the update-config-styling branch from bbfaf24 to d54bf75 Compare June 6, 2026 21:24
@frankslin

frankslin commented Jun 6, 2026 •

Copy link
Copy Markdown
Collaborator Author

在 #366 中 tw2sp.json 的 conversion chain 已由三层改为两层,但是 s2twp.json 一直未做对应的修改。者导致 s2twp 转换时,经过 TWPhrases 词表匹配一次后,还会再被 TWVariantsPhrases 和 TWVariants 转一次。

此问题近期由 @danny0838 编辑「喫茶小舖」等词时重新发现 #1027,故作调整。

验证:扫描了 TWPhrases.txt 当前版本的所有输出值,均不包含 TWVariantsPhrases.txt 及 TWVariants.txt 的输入字词(如 「喫 -> 吃」、「皁 -> 皂」、「羣 -> 群」、「裏 -> 裡」等。也就是说本次修改是不会影响任何转换结果的。

Format all data/config JSON files in a more readable compact style.

Change s2twp so TWPhrases participates in the same grouped conversion stage as TWVariantsPhrases and TWVariants. This means a TWPhrases match is treated as the final phrase conversion for that span instead of continuing through the later Taiwan variant stage, making the forward chain symmetric with the reverse tw2sp chain.

Verified with: bazel test //data/config:config_dict_validation_test; bazel test //test:command_line_converter_test.
@frankslin
frankslin force-pushed the update-config-styling branch from d54bf75 to 220cc3d Compare June 7, 2026 00:20

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 220cc3dc98

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread data/config/s2twp.json
Comment thread plugins/jieba/data/config/s2twp_jieba.json
@danny0838

Copy link
Copy Markdown
Contributor

有沒有考慮改成預設縮排二格的輸出?

即 JSON.stringify(input, null, 2),這樣未來加減值時也可以直接自動排版。

@frankslin

frankslin commented Jun 7, 2026 •

Copy link
Copy Markdown
Collaborator Author

我是用 dprint 及如下配置格式化的(关键点在 preferSingleLine),感觉可读性比全部 2-character indent 稍高一些:

{
  "json": {
    "indentWidth": 2,
    "lineWidth": 80,
    "preferSingleLine": true
  },
  "excludes": [
    "**/*-lock.json"
  ],
  "plugins": [
    "https://plugins.dprint.dev/json-0.21.3.wasm"
  ]
}

很多其他工具也支持。

这种格式还有一个额外的好处,就是 diff 的时候会比纯粹 JSON.stringify(input, null, 2) 清楚一些。修改也会容易一些。

@frankslin
frankslin merged commit 6fd4196 into BYVoid:master Jun 7, 2026
31 checks passed
@frankslin
frankslin deleted the update-config-styling branch June 7, 2026 02:15
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