Skip to content

feat: support nbest output in normalize/tag#348

Merged
pengzhendong merged 1 commit into
masterfrom
feat/nbest
Jun 9, 2026
Merged

feat: support nbest output in normalize/tag#348
pengzhendong merged 1 commit into
masterfrom
feat/nbest

Conversation

@pengzhendong

@pengzhendong pengzhendong commented Jun 9, 2026

Copy link
Copy Markdown
Member

Closes #296

Summary

Add nbest parameter to normalize() and tag():

  • normalize(input) — returns a single string (default, backward compatible)
  • normalize(input, nbest=N) — returns a list of N-best results

Examples

from tn.chinese.normalizer import Normalizer
n = Normalizer()

n.normalize('海淀区108号', nbest=3)
# ['海淀区一百零八号', '海淀区十八号', '海淀区幺零八号']

n.normalize('收费24.0', nbest=3)
# ['收费二十四点零', '收费二四点零', '收费2四点零']

Test plan

  • All 1400 unit tests pass (backward compatible, default nbest=1)
  • CI passes

normalize(input, nbest=1) returns a single string (default, backward
compatible). normalize(input, nbest=N) returns a list of N-best results.

Example:
  n.normalize('海淀区108号', nbest=3)
  # ['海淀区一百零八号', '海淀区十八号', '海淀区幺零八号']
@pengzhendong pengzhendong merged commit 8cc6aee into master Jun 9, 2026
1 check passed
@pengzhendong pengzhendong deleted the feat/nbest branch June 9, 2026 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TN和ITN支持生成不同的结果吗?

1 participant