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 accent debugging to spell check #27

Merged
merged 2 commits into from
Jan 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 18 additions & 11 deletions scripts/spell-check.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,24 @@ files <- c(files, quiz_files)
files <- grep("About.Rmd", files, ignore.case = TRUE, invert = TRUE, value = TRUE)
files <- grep("style-sets", files, ignore.case = TRUE, invert = TRUE, value = TRUE)

# Run spell check
sp_errors <- spelling::spell_check_files(files, ignore = dictionary)

if (nrow(sp_errors) > 0) {
sp_errors <- sp_errors %>%
data.frame() %>%
tidyr::unnest(cols = found) %>%
tidyr::separate(found, into = c("file", "lines"), sep = ":")
} else {
sp_errors <- data.frame(errors = NA)
}
tryCatch(
expr = {
# Run spell check
sp_errors <- spelling::spell_check_files(files, ignore = dictionary)

if (nrow(sp_errors) > 0) {
sp_errors <- sp_errors %>%
data.frame() %>%
tidyr::unnest(cols = found) %>%
tidyr::separate(found, into = c("file", "lines"), sep = ":")
} else {
sp_errors <- data.frame(errors = NA)
}
},
error = function(e){
message("Spell check did not work. Check that your dictionary is formatted correctly. You cannot have special characters (e.g., Diné) in the dictionary.txt file. You need to use HTML formatting (e.g., Din&eacute;) for these.")
}
)

# Print out how many spell check errors
write(nrow(sp_errors), stdout())
Expand Down
Loading