Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected behavior in CharTokenizer when setting split_with_space=True and non_lang_syms is not None #2707

Open
mlxu995 opened this issue Mar 7, 2025 · 3 comments · May be fixed by #2709

Comments

@mlxu995
Copy link
Contributor

mlxu995 commented Mar 7, 2025

An unexpected empty character appears in the output when using CharTokenizer with split_with_space=True to process text containing non-language symbols.
Input text: "你 好 问 问 <NIHAO_WENWEN>" (characters separated by spaces, <NIHAO_WENWEN> is a non-language symbol)
Expected output: ['你', '好', '问', '问', '<NIHAO_WENWEN>']
Actual output: ['你', '好', '问', '问', '', '<NIHAO_WENWEN>'] (contains an unexpected empty character)

I would like to change parts = [w for w in parts if len(w.strip()) > 0] to parts = [w.strip() for w in parts if len(w.strip()) > 0] in char_tokenizer.py line 42

This modification will affect tokens with leading or trailing spaces, and I am not sure if it has some side effects.

@mlxu995
Copy link
Contributor Author

mlxu995 commented Mar 7, 2025

@Mddct 周哥给看下呗

@Mddct
Copy link
Collaborator

Mddct commented Mar 7, 2025

提个pr修一下 顺便测测不split的时候 表现是否正常

@mlxu995
Copy link
Contributor Author

mlxu995 commented Mar 10, 2025

提个pr修一下 顺便测测不split的时候 表现是否正常

Image符合预期,然后不split时同样无法支持英文

@mlxu995 mlxu995 linked a pull request Mar 10, 2025 that will close this issue
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 a pull request may close this issue.

2 participants