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

return String instead of PragmaticSegmenter::Text #38

Open
maia opened this issue Mar 12, 2018 · 0 comments
Open

return String instead of PragmaticSegmenter::Text #38

maia opened this issue Mar 12, 2018 · 0 comments

Comments

@maia
Copy link
Contributor

maia commented Mar 12, 2018

Currently pragmatic_segmenter returns an instance of PragmaticSegmenter::Text, which is a subclass of String. As pragmatic_tokenizer checks if text.class == String and also returning segmented objects of a different class than initially passed, I suggest to return strings instead of instances of the only internally used subclass.

I wonder if there is a smarter idea than using #to_s when returning the result, as it would unnecessarily duplicate the strings in memory. Maybe instead of using a subclass of String rather extend the String class with a module providing that single method used? (and use a method name which won't have a chance to mess with anyones code surprisingly if they also decide to extend the String class)

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