Skip to content

Commit

Permalink
[tn] english, fix <p> (#251)
Browse files Browse the repository at this point in the history
  • Loading branch information
xingchensong committed Jun 25, 2024
1 parent fd566f4 commit eacfc8b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
14 changes: 9 additions & 5 deletions tn/english/rules/punctuation.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,15 @@ def build_tagger(self):
punct = closure(self.punct | cross('\\', '\\\\\\') | cross('"', '\\"'),
1)

emphasis = (
self.emphasis = (
accep("<") +
((
closure(self.NOT_SPACE - union("<", ">"), 1) + # noqa
closure(accep("/"), 0, 1)) # noqa
| (accep("/") + closure(self.NOT_SPACE - union("<", ">"), 1))) +
accep(">")) # noqa
punct = plurals._priority_union(emphasis, punct, closure(self.VCHAR))
punct = plurals._priority_union(self.emphasis, punct,
closure(self.VCHAR))

self.graph = punct
final_graph = insert("v: \"") + add_weight(
Expand All @@ -78,7 +79,10 @@ def build_tagger(self):

def build_verbalizer(self):
punct = closure(
self.punct | cross('\\\\\\', '\\') | cross('\\"', '"')
| accep(" "), 1)
verbalizer = delete('v: "') + punct + delete('"')
self.punct | self.emphasis | cross('\\\\\\', '\\')
| cross('\\"', '"'), 1)
verbalizer = delete('v: "') + add_weight(accep(" "), -1.0).star \
+ punct \
+ add_weight(accep(" "), -1.0).star \
+ delete('"')
self.verbalizer = self.delete_tokens(verbalizer)
1 change: 1 addition & 0 deletions tn/english/test/data/normalizer.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ The National Map, accessed April 1, 2011" Site Description of Koppers Co. From t
The museum is open Mon.-Sun. children of 3-4 years 123 The plan will help you lose 3-4 pounds the first week, and 1-2 pounds the weeks thereafter. => The museum is open Monday to Sunday children of three to four years one hundred and twenty three The plan will help you lose three to four pounds the first week, and one to two pounds the weeks thereafter.
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.

0 comments on commit eacfc8b

Please sign in to comment.