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

Add tokens_keep and dfm_keep? #1037

Closed
koheiw opened this issue Nov 1, 2017 · 2 comments
Closed

Add tokens_keep and dfm_keep? #1037

koheiw opened this issue Nov 1, 2017 · 2 comments
Assignees
Labels

Comments

@koheiw
Copy link
Collaborator

koheiw commented Nov 1, 2017

We have tokens_remove(), which is a shortcut to tokens_select(x, selection = 'remove'), but not tokens_keep(). It makes our life easier, especially with regex patters.

For example, we have to write to keep capitalized words

tokens_select(toks, '^[A-Z]', 'keep', 'regex', FALSE)
# or 
tokens_select(toks, '^[A-Z]', valuetype = 'regex', case_insensitive = FALSE)

These become just

tokens_keep(toks, '^[A-Z]', 'regex', FALSE)

The same apply to dfm_select().

Am I too lazy?

@kbenoit
Copy link
Collaborator

kbenoit commented Nov 1, 2017

You're right, it's consistent, but also a slippery slope: we would then need tokens_keep(), and fcm_keep(). But hey, why not. Look at how many functions stringi has!

@koheiw
Copy link
Collaborator Author

koheiw commented Nov 1, 2017

Short cut functions do not harm anyone as far as they are consistent.

@koheiw koheiw closed this as completed Nov 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants