Skip to content

Commit

Permalink
feat(tn): add args (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
xingchensong authored Nov 13, 2023
1 parent b467a33 commit e0adb16
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion tn/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

# TODO(pzd17): multi-language support
from tn.chinese.normalizer import Normalizer
from itn.main import str2bool


def main():
Expand All @@ -27,10 +28,30 @@ def main():
help='cache dir containing *.fst')
parser.add_argument('--overwrite_cache', action='store_true',
help='rebuild *.fst')
parser.add_argument('--remove_interjections', type=str,
default='True',
help='remove interjections like "啊" and "儿"')
parser.add_argument('--traditional_to_simple', type=str,
default='True',
help='i.e., "喆" -> "哲"')
parser.add_argument('--remove_puncts', type=str,
default='False',
help='remove punctuations like "。" and ","')
parser.add_argument('--full_to_half', type=str,
default='True',
help='i.e., "A" -> "A"')
parser.add_argument('--tag_oov', type=str,
default='False',
help='tag OOV with "OOV"')
args = parser.parse_args()

normalizer = Normalizer(cache_dir=args.cache_dir,
overwrite_cache=args.overwrite_cache)
overwrite_cache=args.overwrite_cache,
remove_interjections=str2bool(args.remove_interjections),
traditional_to_simple=str2bool(args.traditional_to_simple),
remove_puncts=str2bool(args.remove_puncts),
full_to_half=str2bool(args.full_to_half),
tag_oov=str2bool(args.tag_oov))

if args.text:
print(normalizer.tag(args.text))
Expand Down

0 comments on commit e0adb16

Please sign in to comment.