Repository navigation
Conversation
load_seg_dict indexed the first field of every line, so a blank or whitespace-only line (for example a trailing empty line) raised IndexError and CharTokenizer(seg_dict=...) could not be built.
LauraGPT
added a commit
that referenced
this pull request
Nov 15, 2026
Preserve original #3903 ancestry. Scoped CPU and real native CUDA CTC input evidence; exact NumPy matrix CI accepted. No full-repository or pretrained quality claim. Signed-off-by: LauraGPT <zhifu.gzf@alibaba-inc.com>
2 of 9 tasks
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
load_seg_dictinfunasr/tokenizer/char_tokenizer.pyreads the first field of every line without checking it. A seg_dict file with a blank or whitespace-only line (for example a trailing empty line) makesCharTokenizer(seg_dict=...)fail during construction:This change skips empty lines, so the tokenizer loads and tokenizes as expected:
Type of change
Validation
tests/test_char_tokenizer_seg_dict.py. It fails withIndexErrorbefore the change and passes after.python -m pytest tests/test_char_tokenizer_seg_dict.py tests/test_char_tokenizer_non_linguistic_symbols.py: 4 passedpython -m compileall funasr examples tests(rancompileallon the two changed files only)User impact
Users who pass a seg_dict (
seg_dict/seg_dict_file) that contains blank lines can build the tokenizer instead of hitting anIndexError.Notes for reviewers
Two-line change. Non-empty lines are parsed exactly as before.
funasr/models/seaco_paraformer/model.pyandfunasr/models/contextual_paraformer/model.pyhave their own copies ofload_seg_dictwith the same pattern; they are left unchanged here to keep this PR focused.