-
-
Notifications
You must be signed in to change notification settings - Fork 33
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
Return source white space string #95
base: master
Are you sure you want to change the base?
Conversation
Thank you, this looks like an excellent change. Thank you also for including tests. It may take me a little bit to review it, but I'll check it over and get it included. |
Thanks for your reply! |
Escape characters make the source easier to read.
Sorry it took me a while to get to this. The basic code is good, but because of the way MeCab does memory management, it has the issue that the surface is invalidated by further calls to from fugashi import Tagger
tagger = Tagger()
x = tagger("a\nb")
print(repr(x[1].white_space))
# => '\n'
y = tagger("a\tb")
print(repr(x[1].white_space))
# => '\t' (this is wrong) The solution is to cache the white space, as is done for the token surfaces. I can add this myself. |
OK, caching is implemented so this should actually work now. I will do a few more checks before merging. Might take a little while, though it shouldn't be another three weeks 😅 |
Thank you so much!! 😆 |
Currently,
Node.white_space
always returns half-width space" "
(0x20).However, it is not desirable behavior in my use case because I want to preserve source white space characters other than
" "
(e.g.,"\t"
) also.By this PR, the function will return the original white space string.