Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- words <- c("This is a passage where TTR is falling and falling and falling falling more.")
- T1 <- tokenize(words)
- ntype(T1$text1[1:7]) # ISSUE: This generates 7 elements, not 1 number summarizing the number types... So it doesn't count the number of types (which is 2 after the first 7 words).
- # UNLISTING DOES NOT WORK EITHER
- T1$text1 %>% unlist %>% .[1:7] %>% ntype()
- # Idea for a function
- rolling_TTR <- function(passage){
- crawl_text <- NA
- for(i in 1:10) {
- Numerator[i] <- passage$text1[1:i] %>%
- ntype() %>%
- Denominator[i] <- passage$text1[1:i] %>%
- ntoken() %>%
- crawl_text[i] <- Numerator[i]/Denominator[i]
- }
- return(crawl_text)
- }
Add Comment
Please, Sign In to add comment