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

unnest_character_shingles() to_lower is a bit awkward #208

Closed
ahjames11 opened this issue Apr 11, 2022 · 2 comments
Closed

unnest_character_shingles() to_lower is a bit awkward #208

ahjames11 opened this issue Apr 11, 2022 · 2 comments

Comments

@ahjames11
Copy link

When using unnest_character_shingles(), you need to specify both to_lower = FALSE and lowercase = FALSE in order to not convert the tokens to lowercase. It would be nice if to_lower functioned on its own. This is with version 0.3.2

library(tidytext)
library(dplyr)

df <- tibble(text = "ABC")

df %>% 
  unnest_character_shingles(text, text, n = 2L, to_lower = FALSE) 
#> # A tibble: 2 x 1
#>   text 
#>   <chr>
#> 1 ab   
#> 2 bc

df %>% 
  unnest_character_shingles(text, text, n = 2L, lowercase = FALSE) 
#> # A tibble: 2 x 1
#>   text 
#>   <chr>
#> 1 ab   
#> 2 bc

df %>% 
  unnest_character_shingles(text, text, n = 2L, to_lower = FALSE, lowercase = FALSE) 
#> # A tibble: 2 x 1
#>   text 
#>   <chr>
#> 1 AB   
#> 2 BC

Created on 2022-04-11 by the reprex package (v2.0.0)

@juliasilge
Copy link
Owner

Thank you so much for the report @ahjames11! 🙌

This is now fixed:

library(tidytext)
library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union

df <- tibble(text = "ABC")

df %>% 
  unnest_character_shingles(text, text, n = 2L, to_lower = FALSE) 
#> # A tibble: 2 × 1
#>   text 
#>   <chr>
#> 1 AB   
#> 2 BC

Created on 2022-04-13 by the reprex package (v2.0.1)

@github-actions
Copy link

This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.

@github-actions github-actions bot locked and limited conversation to collaborators Apr 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants