Skip to content

Commit

Permalink
[tn] english, support money
Browse files Browse the repository at this point in the history
  • Loading branch information
xingchensong committed Jun 2, 2024
1 parent 5b5ca76 commit 596c8e3
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions tn/english/normalizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from tn.english.rules.date import Date
from tn.english.rules.time import Time
from tn.english.rules.measure import Measure
from tn.english.rules.money import Money

from pynini.lib.pynutil import add_weight, delete
from importlib_resources import files
Expand All @@ -43,10 +44,11 @@ def build_tagger(self):
date = add_weight(Date().tagger, 0.99)
time = add_weight(Time().tagger, 1.00)
measure = add_weight(Measure().tagger, 1.00)
money = add_weight(Money().tagger, 1.00)
word = add_weight(Word().tagger, 100)
tagger = (cardinal | ordinal | word
| date | decimal | fraction
| time | measure).optimize() + self.DELETE_SPACE
| time | measure | money).optimize() + self.DELETE_SPACE
# delete the last space
self.tagger = tagger.star @ self.build_rule(delete(' '), r='[EOS]')

Expand All @@ -59,8 +61,9 @@ def build_verbalizer(self):
date = Date().verbalizer
time = Time().verbalizer
measure = Measure().verbalizer
money = Money().verbalizer
verbalizer = (cardinal | ordinal | word
| date | decimal
| fraction | time
| measure).optimize() + self.INSERT_SPACE
| measure | money).optimize() + self.INSERT_SPACE
self.verbalizer = verbalizer.star

0 comments on commit 596c8e3

Please sign in to comment.