Skip to content

Commit

Permalink
remove redundant character counts
Browse files Browse the repository at this point in the history
get_words function was counting characters in all words. This is
unnecessary since many words are repeated. This fix will improve the
speed of the 'word method' password generation. Partially resolves #2.
  • Loading branch information
bbartholdy committed Nov 10, 2024
1 parent 7cfa73a commit f9e6277
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pw_methods <- function(){
get_words <- function(){
utils::data("lotr", envir = environment())
text_datf <- data.frame(txt = lotr)
words_datf <- tidytext::unnest_tokens(text_datf, word, txt, to_lower = F)
words_datf <- dplyr::distinct(tidytext::unnest_tokens(text_datf, word, txt, to_lower = F))
words_datf$count <- apply(words_datf, MARGIN = 1, nchar)
return(words_datf)
}
Expand Down

0 comments on commit f9e6277

Please sign in to comment.