Skip to content

[style] 纠正规则支持正则表达式和动态替换 #1515

Backlog

Description

@HKLHaoBin

现象

当前「纠正规则」主要是固定文本替换,当前实现只支持字面替换以及一个 {num} 数字通配符。对于同一种错误模式中包含不同数字、词段或其他可变内容的情况,需要为每种情况重复配置规则,无法用表达式统一处理。

例如,希望能够配置类似下面的规则:

  • 匹配:(\d+)粒
  • 替换:$1例

这样即可将「3粒」「20粒」等内容统一改为「3例」「20例」,而不必逐个添加固定字符串规则。

影响

  • 规则数量会随着可变内容快速膨胀,维护成本高。
  • 无法覆盖带编号、不同后缀或其他动态片段的常见识别错误。
  • 纠正规则的表达能力明显受限,难以满足专业术语和固定格式文本的纠正需求。

建议接受标准

  • 纠正规则支持可选的表达式匹配模式(至少覆盖常用正则表达式能力)。
  • 支持捕获组在替换文本中回填,例如 $1 或项目最终确定的等价语法。
  • 现有字面替换规则和 {num} 规则保持兼容,不要求用户迁移已有配置。
  • 表达式编译失败、替换引用无效等情况在设置界面给出明确提示,且不能导致语音输入主流程失败。
  • 在帮助文档中说明表达式语法、转义规则、匹配范围和可直接使用的示例。

TODO / 不确定项

  • 具体采用 Rust regex 语法、其他兼容语法,还是更受限的策略表达式,由实现设计时确定。
  • 是否提供大小写、全局匹配、Unicode 等选项,由实现设计时确定。

Activity

  1. added
    enhancement
    P3
    needs-design
    area:style
    on Nov 29, 2026
  2. HKLHaoBin commented on Dec 1, 2026

    @HKLHaoBin
    CollaboratorAuthor

    Android APK artifacts available for testing

    The Android release workflow completed successfully for:

    Open the run page and use its Artifacts section to download the matching package:

    • openless-android-release-arm64-v8a — 69,431,869 bytes — archive digest sha256:94e2bb57fd58ddcd5aff87258aff870e68774f34fc3e823a94c2f9e61d2b998f
    • openless-android-release-armeabi-v7a — 57,745,385 bytes — archive digest sha256:41136dab53fc3f538b2d401ac2b9a5018aaf286b5cc2b574041036d315d53121
    • openless-android-release-x86_64 — 59,936,975 bytes — archive digest sha256:bb94a059790fcbabd8b798cc083aa6f512eb4e7db0e646b37bf618bad3237bd3
    • openless-android-release-x86 — 60,409,726 bytes — archive digest sha256:faad745f62a2104602f7c128f1b87840a7583ea0cd9f2182056d3961c60e4dc8

    The artifacts expire on December 14, 2026. GitHub allows the run page to be viewed publicly, but may require you to sign in before downloading an Actions artifact. The previous direct REST download links were removed because they return HTTP 401 when opened without authentication.

    Download the ZIP, extract the APK for the device ABI, install it, and test the correction-rule flow, including a literal rule, {num}, and an explicit regex rule such as ([0-9]+)粒 → $1例.

    The archive digests identify the uploaded ZIP archives, not the APK files inside them. Device installation and behavior remain pending user testing. The Android workflow passed. CI run 46444881088 attempt 2 completed with failures in unchanged upstream beta paths; it is not being claimed as a pass. See Draft PR #1522 for the full status.

  3. HKLHaoBin commented on Dec 1, 2026

    @HKLHaoBin
    CollaboratorAuthor

    Desktop build artifacts available for testing

    The desktop release workflow completed successfully for the exact WIP PR head:

    • Branch: feat/issue-1515-correction-expressions
    • Commit: 33618fae405179f916c0c50d6de53b23f81b7f45
    • Open the public Actions run page
    • Required build jobs: Windows x64, macOS Intel x86_64, and macOS Apple Silicon ARM64 — all passed.

    Open the run page and use its Artifacts section to download the matching package:

    • openless-windows-x64 — 122,303,887 bytes — archive digest sha256:d677fd883ece86c7767108563e41be66bae5d356d693360493df8316f5686a8b
    • openless-windows-x64-updater — 1,839 bytes — archive digest sha256:f4f739f3c1dfcfc63839f902f54e0903902b3afe19540c1997d4ce85a08da706
    • openless-macos-aarch64 — 42,948,988 bytes — archive digest sha256:a3c7d5e5bb18e7af72fe36faa16753d6ab2c92979764ffe156ac155922e792df
    • openless-macos-aarch64-updater — 39,731,380 bytes — archive digest sha256:9784e5821fdd4bb1d536c498abe52ca9e0eee7627a620cb72e4b83a5c6c40452
    • openless-macos-x86_64 — 44,667,700 bytes — archive digest sha256:f478cfa5845168c4131c795f2b728706d010668b9fe5eb1909a36a0ea1ae5858
    • openless-macos-x86_64-updater — 43,101,241 bytes — archive digest sha256:4b5c6c15f471c5d733869e4846f2b3fecbec4e17b6b0ef54104bd51581d93576

    Apple Silicon artifacts expire December 15, 2026; Windows and Intel macOS artifacts expire December 14, 2026. GitHub allows the run page to be viewed publicly, but may require you to sign in before downloading an Actions artifact. The previous direct REST and artifact-detail links were removed because they return HTTP 401/404 when opened without authentication.

    Download the ZIP for the platform, extract the installer/package, install it, and test the correction-rule flow. Please test an existing literal rule, {num}, and an explicit regex rule such as ([0-9]+)粒 → $1例.

    The listed digests identify the uploaded Actions archives, not the installer files inside them. This is a WIP build; installation and behavior acceptance are still requested from the tester. Desktop passed. CI run 46444881088 attempt 2 completed with failures in unchanged upstream beta paths; it is not being claimed as a pass. See Draft PR #1522 for the full status.

  4. HKLHaoBin commented on Dec 1, 2026

    @HKLHaoBin
    CollaboratorAuthor

    Android artifact — current head verified

    The workflow built the release APK, collected the split APK, and uploaded the artifact successfully. This is an artifact/build verification only; no physical-device installation or runtime acceptance was performed.

    The dispatch fast profile produced the arm64-v8a artifact only. CI and desktop runs for this same head are still pending.

  5. HKLHaoBin commented on Dec 2, 2026

    @HKLHaoBin
    CollaboratorAuthor

    Desktop artifacts — current head partial milestone

    Verified Windows x64 artifacts

    Verified macOS Intel x86_64 artifacts

    Verified updater artifacts

    The Apple Silicon macOS artifact was not produced because its job was cancelled. Android for this head was verified separately in the previous comment.

  6. HKLHaoBin commented on Dec 2, 2026

    @HKLHaoBin
    CollaboratorAuthor

    Android artifact — latest head verified

    The workflow built the release APK, collected the split APK, and uploaded the artifact successfully. This is an artifact/build verification only; no physical-device installation or runtime acceptance was performed.

    The dispatch fast profile produced the arm64-v8a artifact only.

  7. HKLHaoBin commented on Dec 2, 2026

    @HKLHaoBin
    CollaboratorAuthor

    Desktop artifacts — latest head downloaded for testing

    Download from GitHub Actions Artifacts

    The Windows installer, Windows executable/PDB, macOS Intel DMG, updater files, and provenance files were downloaded and hash-verified locally. The Apple Silicon macOS artifact was not produced because that job was cancelled.

    Android arm64-v8a for the same head was published separately at: #1515 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3area:styleenhancementneeds-design

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions