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

remove_words! fails for long terms & terms with punctuation #74

Open
enkiv2 opened this issue Apr 6, 2018 · 6 comments
Open

remove_words! fails for long terms & terms with punctuation #74

enkiv2 opened this issue Apr 6, 2018 · 6 comments

Comments

@enkiv2
Copy link

enkiv2 commented Apr 6, 2018

Because remove_words! uses regex matching even for string input, it fails on actually-present terms if those terms are larger than the maximum pattern size accepted by PCRE. Actually-present terms also fail if they contain regex-like punctuation. This produces an error message that doesn't specify the failed pattern, and furthermore aborts remove_words! entirely.

The same problem occurs in remove_sparse_terms! and remove_frequent_terms!, since these also file down to a call to remove_pattern.

Would it be possible to force only string-literal substitution in the case where an array of type String is passed (and only use regex if the items passed are actually typed as regular expressions)?

@aviks
Copy link
Member

aviks commented Apr 8, 2018

Might be a good idea. Will need some thought on how to deprecate the existing behaviour. Care to do a PR?

@enkiv2
Copy link
Author

enkiv2 commented Apr 11, 2018

Well, I have a naive solution that works for StringDocument; unfortunately, it has major performance problems. Should I submit a PR or wait until I've figured out how to get reasonable performance out of it?

@aviks
Copy link
Member

aviks commented Jun 11, 2018

I'd say submit a PR. We can figure out performance later. Slow code is better than no code.

@enkiv2
Copy link
Author

enkiv2 commented Jun 11, 2018

PR: #76

Because of string copying overhead, for situations big enough for the regex size to matter, it's unusably slow. However, in the absence of reliable regex escaping, this has reliability benefits.

@Ayushk4
Copy link
Member

Ayushk4 commented May 14, 2019

I think a better way to solve this issue could be using a TokenBuffer which is currently used by the tokenizers in WordTokenizers.jl. ( #143 )

@enkiv2
Copy link
Author

enkiv2 commented May 14, 2019 via email

@Ayushk4 Ayushk4 mentioned this issue Jun 23, 2019
14 tasks
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.

3 participants