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

Need (internal?) tokens_split() #1500

Closed
kbenoit opened this issue Nov 19, 2018 · 3 comments
Closed

Need (internal?) tokens_split() #1500

kbenoit opened this issue Nov 19, 2018 · 3 comments
Milestone

Comments

@kbenoit
Copy link
Collaborator

kbenoit commented Nov 19, 2018

This would resolve the inefficiency noted here but with a general solution. I actually started writing this based on the (internal) tokens_segment() but then went for a quicker fix since I only needed an internal hyphen solution for

quanteda/R/tokens.R

Lines 221 to 225 in 0dc5b34

if (remove_hyphens && any(stri_detect_regex(types(x), "^.+-.+$"))) {
x <- lapply(as.list(x), function(y)
as.character(tokens(as.character(y), remove_hyphens = TRUE))) %>%
as.tokens()
}

Proposal:

tokens_split(x, pattern, valuetype = c("glob", "regex", "fixed"),
  case_insensitive = TRUE, keep_pattern = FALSE)

which would be the opposite direction, otherwise similar behaviour, to tokens_compound().

@kbenoit
Copy link
Collaborator Author

kbenoit commented Nov 20, 2018

BTW here I implemented a hyphen-specific version for dfm features here, probably about as efficiently it's possible to do in straight R.

But it's easier for a dfm than for tokens because a) can use column indexing from matrices and b) feature order does not matter for dfm.

@kbenoit
Copy link
Collaborator Author

kbenoit commented Nov 20, 2018

To Do: Reimplement the inefficient solution to #1498 once tokens_split() is working.

@kbenoit kbenoit added this to the v1.4 milestone Dec 18, 2018
@kbenoit
Copy link
Collaborator Author

kbenoit commented Dec 27, 2018

Solved in #1520 via tokens_chunk().

@kbenoit kbenoit closed this as completed Dec 27, 2018
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