Skip to content

Commit b1c7af4

Browse files
authored
fix: resolve 16 failing unit tests (#332)
* fix: resolve 16 failing unit tests across Chinese ITN, Japanese ITN, and English TN - Chinese ITN: prefer currency symbol ($) over ISO code (USD) by adding weight to code FST in money rule - Japanese ITN: fix big_integer FST structure to prevent 三十 being split into 3+10=310 instead of parsed as 30 - English TN: prefer "oh" over "zero" for digit 0 in non-deterministic mode by adding weight to zero path - English TN: fix whitelist test expectation for Hon. -> Honorable * refactor: deduplicate whitelist entries in tts.tsv Remove entries from tts.tsv that duplicate mappings in alternatives.tsv (Hon., Mr., Mrs., Ms.) or are self-duplicated Greek letters (κ, ω, α, ν, δ, Δ, Α, β, Β). This avoids non-deterministic FST behavior across platforms when the same key maps to different values in unioned files.
1 parent 160a126 commit b1c7af4

5 files changed

Lines changed: 8 additions & 23 deletions

File tree

itn/chinese/rules/money.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414

1515
from pynini import string_file
16-
from pynini.lib.pynutil import delete, insert
16+
from pynini.lib.pynutil import add_weight, delete, insert
1717

1818
from itn.chinese.rules.cardinal import Cardinal
1919
from tn.processor import Processor
@@ -42,7 +42,7 @@ def build_tagger(self):
4242
+ number
4343
+ insert('"')
4444
+ insert(' currency: "')
45-
+ (code | symbol)
45+
+ (symbol | add_weight(code, 1))
4646
+ insert('"')
4747
+ insert(' decimal: "')
4848
+ (insert(".") + digit + (delete("毛") | delete("角")) + (digit + delete("分")).ques).ques

itn/japanese/rules/cardinal.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,17 +122,13 @@ def build_tagger(self):
122122
(ten_thousand_minus + accep("兆")).ques
123123
+ ten_thousand_minus
124124
+ accep("億")
125-
+ ten_thousand_minus
126-
+ accep("万").ques
127-
+ ten_thousand_minus.ques
125+
+ (ten_thousand_minus + (accep("万") + ten_thousand_minus.ques).ques).ques
128126
)
129127
| (
130128
ten_thousand_minus
131129
+ accep("兆")
132130
+ (ten_thousand_minus + accep("億")).ques
133-
+ ten_thousand_minus
134-
+ accep("万").ques
135-
+ ten_thousand_minus.ques
131+
+ (ten_thousand_minus + (accep("万") + ten_thousand_minus.ques).ques).ques
136132
)
137133
)
138134
self.big_integer = number | big_integer

tn/english/data/whitelist/tts.tsv

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
Ph.D. PHD
2-
Hon. honorable
32
Mt. Mount
43
Maj. Major
54
Rev. Reverend
@@ -15,15 +14,6 @@ HVAC H-vac
1514
SPDR spider
1615
ZIP zip
1716
~ approximately
18-
κ kappa
19-
ω omega
20-
α alpha
21-
ν nu
22-
δ delta
23-
Δ delta
24-
Α alpha
25-
β beta
26-
Β beta
2717
χ chi
2818
Χ chi
2919
ε epsilon
@@ -1934,16 +1924,13 @@ M. Q. MQ
19341924
Mra MRA
19351925
MRBs MRB's
19361926
MR&LE MR and LE
1937-
Mr. mister
19381927
M. R. MR
19391928
M.R. MR
19401929
mRNA MRNA
19411930
mRNAs MRNA's
1942-
Mrs. misses
19431931
MRTs MRT's
19441932
Mse MSE
19451933
M&S M and S
1946-
Ms. miss
19471934
M. S. MS
19481935
M.S. MS
19491936
MSPs MSP's

tn/english/rules/cardinal.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ def build_tagger(self):
5858
single_digits_graph_zero = pynini.invert(graph_digit | graph_zero)
5959
single_digits_graph_oh = pynini.invert(graph_digit) | pynini.cross("0", "oh")
6060

61-
self.single_digits_graph = single_digits_graph_zero + (self.INSERT_SPACE + single_digits_graph_zero).star
61+
self.single_digits_graph = pynutil.add_weight(
62+
single_digits_graph_zero + (self.INSERT_SPACE + single_digits_graph_zero).star, 1.0
63+
)
6264
self.single_digits_graph |= single_digits_graph_oh + (self.INSERT_SPACE + single_digits_graph_oh).star
6365

6466
single_digits_graph_with_commas = (

tn/english/test/data/whitelist.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Ph.D. => PHD
2-
Hon. => honorable
2+
Hon. => Honorable
33
Mt. => Mount
44
Maj. => Major
55
Rev. => Reverend

0 commit comments

Comments
 (0)