Skip to content

Commit

Permalink
[tn] delete prefix space (#262)
Browse files Browse the repository at this point in the history
  • Loading branch information
xingchensong authored Jul 4, 2024
1 parent 91e51ca commit 2b04bc3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tn/english/normalizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ def build_tagger(self):
| rang
| punct
).optimize() + (punct.plus | self.DELETE_SPACE)
# delete the last space
self.tagger = tagger.star @ self.build_rule(delete(' '), r='[EOS]')
# delete the first and last space
self.tagger = (delete(' ').star + tagger.star) @ self.build_rule(
delete(' '), r='[EOS]')

def build_verbalizer(self):
cardinal = Cardinal().verbalizer
Expand Down
1 change: 1 addition & 0 deletions tn/english/test/data/normalizer.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ The museum is open Mon.-Sun. children of 3-4 years 123 The plan will help you lo
Try searching for 'Toyota' or 'Investment' => Try searching for 'Toyota' or 'Investment'
"" => ""
The HTML tag <p> defines a paragraph. => The HTML tag <p> defines a paragraph.
hello world => hello world

0 comments on commit 2b04bc3

Please sign in to comment.