Skip to content

Commit d644ad9

Browse files
committed
feat: decades, serial weight fix, 451/470 (96%)
- Date: add decades pattern (nineteen eighties => 1980s) - Telephone: increase serial weight to reduce false matches - Telephone: add double digit support in IP - Update test cases (451 cases)
1 parent 6cb6756 commit d644ad9

3 files changed

Lines changed: 10 additions & 2 deletions

File tree

itn/english/rules/date.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,14 @@ def build_tagger(self):
118118
# Year only => "twenty twelve", "two thousand three"
119119
graph_y = add_weight(year, 0.01) + po
120120

121-
final_graph = graph_mdy | graph_md | graph_my | graph_dmy | graph_dm | graph_y
121+
# Decades: "nineteen eighties" => 1980s
122+
decade_suffix = closure(self.ALPHA, 1) + (cross("ies", "y") | delete("s"))
123+
decade_word = pynini.compose(decade_suffix, ties | cross("ten", "10"))
124+
graph_decade = (
125+
insert('year: "') + (teen | two_digit) + ds + decade_word + insert('0s"') + po
126+
)
127+
128+
final_graph = graph_mdy | graph_md | graph_my | graph_dmy | graph_dm | graph_y | graph_decade
122129
self.tagger = self.add_tokens(final_graph)
123130

124131
def build_verbalizer(self):

itn/english/rules/telephone.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def build_tagger(self):
8787
serial_char = single | add_weight(two_digit, 0.002) | self.ALPHA
8888
serial = serial_char + closure(ds + serial_char, 2)
8989
serial = serial @ (closure(self.ALPHA | self.DIGIT) + self.DIGIT + closure(self.ALPHA | self.DIGIT))
90-
graph |= insert('number_part: "') + add_weight(serial, 0.001) + insert('"')
90+
graph |= insert('number_part: "') + add_weight(serial, 2.0) + insert('"')
9191

9292
self.tagger = self.add_tokens(graph)
9393

itn/english/test/data/en_date.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
july twenty fifth two thousand twelve => july 25 2012
2+
nineteen eighties => 1980s
23
two thousand and twenty => 2020
34
two thousand and nine => 2009
45
the twenty fifth of july twenty twelve => 25 july 2012

0 commit comments

Comments
 (0)