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

tokens(x, remove_separators = TRUE) does not remove all separators #796

Closed
kbenoit opened this issue Jun 13, 2017 · 0 comments
Closed

tokens(x, remove_separators = TRUE) does not remove all separators #796

kbenoit opened this issue Jun 13, 2017 · 0 comments
Assignees

Comments

@kbenoit
Copy link
Collaborator

kbenoit commented Jun 13, 2017

Discovered in #784.

For instance:

txt <- "space tab\t newline\n non-breakingspace\u00A0 em-space\u2003 variationselector16 \uFE0F end"

(toks <- tokens(txt, remove_separators = TRUE))
# tokens from 1 document.
# Component 1 :
#  [1] "space"               "tab"                 "newline"             "non"                
#  [5] "-"                   "breakingspace"       "em"                  "-"                  
#  [9] "space"               "variationselector16" " ️"                   "end"                

tokens_wordstem(toks)
#  Error in char_wordstem(types(x), language = language) : 
#   whitespace detected: you can only stem tokenized texts 

This is solvable by removing all \\p{Z}:

tokens_remove(toks, "\\p{Z}", valuetype = "regex")
# tokens from 1 document.
# Component 1 :
#  [1] "space"               "tab"                 "newline"             "non"                
#  [5] "-"                   "breakingspace"       "em"                  "-"                  
#  [9] "space"               "variationselector16" "end"  
kbenoit added a commit that referenced this issue Jun 15, 2017
- removes non-standard spacing characters
- keeps spacing with `remove_punct = TRUE, remove_separators = FALSE` (formerly this also removed separators)
- changes calls to `tokenize()` in `ntoken()`, `ntype()` to `tokens()`
@kbenoit kbenoit mentioned this issue Jun 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants