Skip to content

Commit

Permalink
[fix] fix tn, week range
Browse files Browse the repository at this point in the history
  • Loading branch information
xingchensong committed Jun 6, 2024
1 parent 0f386d8 commit 7c3619b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
18 changes: 18 additions & 0 deletions tn/english/data/date/week.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Mon Monday
Mon. Monday
Tu Tuesday
Tu. Tuesday
Wed Wednesday
Wed. Wednesday
Th Thursday
Th. Thursday
Thur Thursday
Thur. Thursday
Thurs Thursday
Thurs. Thursday
Fri Friday
Fri. Friday
Sat Saturday
Sat. Saturday
Sun Sunday
Sun. Sunday
1 change: 1 addition & 0 deletions tn/english/data/whitelist/alternatives.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ NO. number
NO. number
No. number
VOL. Volume
Vol. Volume
TV Television
8 changes: 7 additions & 1 deletion tn/english/rules/range.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from pynini.lib import pynutil

from tn.processor import Processor
from tn.utils import get_abs_path
from tn.english.rules.cardinal import Cardinal
from tn.english.rules.time import Time
from tn.english.rules.date import Date
Expand Down Expand Up @@ -45,14 +46,19 @@ def build_tagger(self):
time = time.tagger @ time.verbalizer
date = Date(deterministic=self.deterministic)
date = date.tagger @ date.verbalizer
week = pynini.string_file(get_abs_path("english/data/date/week.tsv"))
delete_space = pynini.closure(pynutil.delete(" "), 0, 1)

approx = pynini.cross("~", "approximately")

# WEEK
week_graph = week + delete_space + (pynini.cross("-", " to ")
| approx) + delete_space + week

# TIME
time_graph = time + delete_space + pynini.cross(
"-", " to ") + delete_space + time
self.graph = time_graph | (approx + time)
self.graph = time_graph | (approx + time) | week_graph

# YEAR
date_year_four_digit = (self.DIGIT**4 +
Expand Down

0 comments on commit 7c3619b

Please sign in to comment.