Skip to content

Commit 6ee1abd

Browse files
authored
fix: don't convert - to 减 in non-math context (#347)
* fix: don't convert - to 减 in non-math context (#294) 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 * ci: only test macOS/Windows on schedule and manual dispatch * ci: run macOS/Windows only on manual dispatch, Linux on PR
1 parent 0650fa9 commit 6ee1abd

3 files changed

Lines changed: 9 additions & 2 deletions

File tree

.github/workflows/unittest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
strategy:
1616
fail-fast: false
1717
matrix:
18-
os: [ubuntu-latest, macos-latest, windows-latest]
18+
os: ${{ github.event_name == 'pull_request' && fromJSON('["ubuntu-latest"]') || fromJSON('["ubuntu-latest", "macos-latest", "windows-latest"]') }}
1919
python-version: ['3.9']
2020
steps:
2121
- uses: actions/checkout@v4
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
×
2+
÷
3+
大于等于
4+
小于等于
5+
>= 大于等于
6+
<= 小于等于

tn/chinese/rules/math.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@ def __init__(self, cardinal=None):
3030

3131
def build_tagger(self):
3232
operator = string_file(get_abs_path("chinese/data/math/operator.tsv"))
33+
unambiguous_operator = string_file(get_abs_path("chinese/data/math/operator_unambiguous.tsv"))
3334
symbols = cross("~", "到") | cross(":", "比") | cross("<", "小于") | cross(">", "大于")
3435

3536
number = self.cardinal.number
3637
tagger = number + (delete(" ").ques + (operator | symbols) + delete(" ").ques + number).star
37-
tagger |= operator
38+
tagger |= unambiguous_operator
3839
tagger = insert('value: "') + tagger + insert('"')
3940
self.tagger = self.add_tokens(tagger)

0 commit comments

Comments
 (0)