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

janitor_util C++ splits multibyte characters into non-UTF bytes(?) #1452

Open
mycoalchen opened this issue Feb 21, 2024 · 0 comments
Open

janitor_util C++ splits multibyte characters into non-UTF bytes(?) #1452

mycoalchen opened this issue Feb 21, 2024 · 0 comments

Comments

@mycoalchen
Copy link
Contributor

When I ran janitor.decontaminate(input) from janitor.py in C++ mode, my Python code threw UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe2 in position 86: unexpected end of data. I cleaned my input of non-UTF-8 characters before passing it to decontaminate() by running input = input.encode("utf-32", errors="ignore").decode("utf-32", errors="ignore"), but the error still showed. I suspect the error was caused by the string splitting in janitor_util.cpp's clean_ngram_with_indices. When some multibyte UTF-8 characters are split, the resulting bytes are outside UTF range. For example, the en-dash is \xe2\x80\x93 in UTF-8, but \xe2 is not a UTF character.

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

No branches or pull requests

1 participant