From b3ed6aff8f227ff13bb95fe1b3e46aa2e956df80 Mon Sep 17 00:00:00 2001 From: pengzhendong <275331498@qq.com> Date: Tue, 9 Jun 2026 19:24:15 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix:=20don't=20convert=20-=20to=20=E5=87=8F?= =?UTF-8?q?=20in=20non-math=20context=20(#294)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Split math operators into ambiguous (-, +, =) and unambiguous (×, ÷, ≥, ≤, etc.). Ambiguous operators now require number context on both sides. Unambiguous operators can still match independently. Before: wide-awake => wide减awake After: wide-awake => wide-awake --- tn/chinese/data/math/operator_unambiguous.tsv | 6 ++++++ tn/chinese/rules/math.py | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 tn/chinese/data/math/operator_unambiguous.tsv diff --git a/tn/chinese/data/math/operator_unambiguous.tsv b/tn/chinese/data/math/operator_unambiguous.tsv new file mode 100644 index 00000000..3bef6459 --- /dev/null +++ b/tn/chinese/data/math/operator_unambiguous.tsv @@ -0,0 +1,6 @@ +× 乘 +÷ 除 +≥ 大于等于 +≤ 小于等于 +>= 大于等于 +<= 小于等于 diff --git a/tn/chinese/rules/math.py b/tn/chinese/rules/math.py index ce358bfb..fbc33981 100644 --- a/tn/chinese/rules/math.py +++ b/tn/chinese/rules/math.py @@ -30,10 +30,11 @@ def __init__(self, cardinal=None): def build_tagger(self): operator = string_file(get_abs_path("chinese/data/math/operator.tsv")) + unambiguous_operator = string_file(get_abs_path("chinese/data/math/operator_unambiguous.tsv")) symbols = cross("~", "到") | cross(":", "比") | cross("<", "小于") | cross(">", "大于") number = self.cardinal.number tagger = number + (delete(" ").ques + (operator | symbols) + delete(" ").ques + number).star - tagger |= operator + tagger |= unambiguous_operator tagger = insert('value: "') + tagger + insert('"') self.tagger = self.add_tokens(tagger) From 64348bd3a2c93b8f214ed05ff6a0ca4d89bf7d36 Mon Sep 17 00:00:00 2001 From: pengzhendong <275331498@qq.com> Date: Tue, 9 Jun 2026 19:26:31 +0800 Subject: [PATCH 2/3] ci: only test macOS/Windows on schedule and manual dispatch --- .github/workflows/unittest.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml index 90b49471..5b7c5d08 100644 --- a/.github/workflows/unittest.yml +++ b/.github/workflows/unittest.yml @@ -2,6 +2,8 @@ name: UnitTest on: workflow_dispatch: + schedule: + - cron: '0 3 * * 1' pull_request: paths: - '**.py' @@ -15,7 +17,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, macos-latest, windows-latest] + os: ${{ github.event_name == 'pull_request' && fromJSON('["ubuntu-latest"]') || fromJSON('["ubuntu-latest", "macos-latest", "windows-latest"]') }} python-version: ['3.9'] steps: - uses: actions/checkout@v4 From 6ac89833532bdff6896815d0067e6e6c848f8ab5 Mon Sep 17 00:00:00 2001 From: pengzhendong <275331498@qq.com> Date: Tue, 9 Jun 2026 19:26:55 +0800 Subject: [PATCH 3/3] ci: run macOS/Windows only on manual dispatch, Linux on PR --- .github/workflows/unittest.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml index 5b7c5d08..e1269cb5 100644 --- a/.github/workflows/unittest.yml +++ b/.github/workflows/unittest.yml @@ -2,8 +2,6 @@ name: UnitTest on: workflow_dispatch: - schedule: - - cron: '0 3 * * 1' pull_request: paths: - '**.py'