-
Notifications
You must be signed in to change notification settings - Fork 13
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
Strange characters lyrics #44
Comments
Hi @ericwu17, I'm away from my laptop for a bit, but I'll take a look when I'm back in a couple of weeks. In the meantime feel free to submit a PR with updates to the encoding. If I'm remembering correctly, I tried to run the python script and got an error (I don't use python very often). I do check for encoding in data-raw/taylor-lyrics.R, and that isn't showing any unexpected errors, as in your example, so I'm not sure what is going on. |
I've done a little bit of digging. First, here's what I see when I try to run the python script:
When I search for non-ASCII characters, I see only 17 instances, which are all intentional (e.g., the "é" in café, rosé): library(tidyverse)
library(taylor)
taylor_all_songs %>%
select(album_name, track_name, lyrics) %>%
unnest(lyrics) %>%
select(album_name, track_name, line, lyric) %>%
mutate(across(where(is.character), stringi::stri_enc_isascii,
.names = "{.col}_ascii"
)) %>%
filter(!if_all(ends_with("ascii"))) %>%
mutate(
ascii_flag = map(lyric,
.f = function(.x) {
str_split(.x, "") %>%
flatten_chr() %>%
enframe() %>%
mutate(ascii = map_lgl(
value,
stringi::stri_enc_isascii
)) %>%
filter(!ascii) %>%
select(value, ascii)
}
)
) %>%
unnest(ascii_flag) %>%
select(album_name, track_name, lyric, ascii, value)
#> # A tibble: 17 × 5
#> album_name track_name lyric ascii value
#> <chr> <chr> <chr> <lgl> <chr>
#> 1 Fearless (Taylor's Version) White Horse (Taylor's Version) "May… FALSE ï
#> 2 Red Begin Again "But… FALSE é
#> 3 Red Begin Again "But… FALSE é
#> 4 Red Begin Again "But… FALSE é
#> 5 Red Begin Again "But… FALSE é
#> 6 Red (Taylor's Version) Begin Again (Taylor's Version) "But… FALSE é
#> 7 Red (Taylor's Version) Begin Again (Taylor's Version) "But… FALSE é
#> 8 Red (Taylor's Version) Begin Again (Taylor's Version) "But… FALSE é
#> 9 Red (Taylor's Version) Begin Again (Taylor's Version) "But… FALSE é
#> 10 Red (Taylor's Version) Nothing New (Taylor's Version)… "Peo… FALSE é
#> 11 Lover You Need To Calm Down "But… FALSE ó
#> 12 folklore the 1 "I h… FALSE é
#> 13 folklore the 1 "Ros… FALSE é
#> 14 folklore the last great american dynasty "And… FALSE é
#> 15 folklore the last great american dynasty "And… FALSE í
#> 16 evermore champagne problems "Dom… FALSE é
#> 17 Midnights Maroon "\"Y… FALSE é And I'm not able to reproduce the problem from your example: taylor_all_songs %>%
select(album_name, track_name, lyrics) %>%
unnest(lyrics) %>%
filter(str_detect(lyric, "a brave man"))
#> # A tibble: 1 × 6
#> album_name track_name line lyric element element_artist
#> <chr> <chr> <int> <chr> <chr> <chr>
#> 1 THE TORTURED POETS DEPARTMENT The Black Dog 18 You … Verse 2 Taylor Swift Created on 2024-04-29 with reprex v2.1.0 |
Hi wjakethompson, thanks for the detailed response! I've opened a pull request (#45) which fixes the issue with the python script. You should now be able to run the script and see the lyrics in the If you'd like, I can also open another pull request with changes generated by running the python script. It's curious that you can't reproduce the issue when interacting with the lyrics through R. I am not familiar with how R works, but is it the case that the |
Please briefly describe your problem and what output you expect. Please include a minimal reproducible example (AKA a reprex). If you've never heard of a reprex before, start by reading https://www.tidyverse.org/help/#reprex.
Some lyrics in newer albums have strange characters. For example, the 'e' in the phrase "a brave man" in the song The Black Dog is not a ASCII 'e' but instead some other type of 'e'. This means that if we use grep (or and IDE search feature) to look for the phrase "a brave man", no results are found, even when the phrase is used in the song The Black Dog.
I have previously made a pull request (#2) which added a python script to catch these types of errors, but it seems like the script was not run since the addition of new lyrics.
Having the correct encoding of the lyrics is important to me, since this repository is the upstream for a lyric completion game that I maintain (I am in the process of adding lyrics for TTPD).
Observed behavior:
Expected behavior:
The text was updated successfully, but these errors were encountered: