daily pastebin goal
13%
SHARE
TWEET

Untitled

a guest Mar 8th, 2018 39 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. words <- c("This is a passage where TTR is falling and falling and falling falling more.")
  2.  
  3. T1 <- tokenize(words)
  4.  
  5. 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).
  6.  
  7. # UNLISTING DOES NOT WORK EITHER
  8. T1$text1 %>% unlist %>% .[1:7] %>% ntype()
  9.  
  10.  
  11. # Idea for a function
  12. rolling_TTR <- function(passage){
  13.   crawl_text <- NA
  14.   for(i in 1:10) {
  15.     Numerator[i] <- passage$text1[1:i] %>%
  16.                     ntype() %>%
  17.     Denominator[i] <- passage$text1[1:i] %>%
  18.                     ntoken() %>%
  19.    crawl_text[i] <-  Numerator[i]/Denominator[i]
  20.   }
  21.   return(crawl_text)
  22. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top