|
148 | 148 | #' sandwich.") |
149 | 149 | #' tokens(txt) %>% |
150 | 150 | #' textstat_lexdiv(measure = c("TTR", "CTTR", "K")) |
151 | | -#' dfm(txt) %>% |
| 151 | +#' dfm(tokens(txt)) %>% |
152 | 152 | #' textstat_lexdiv(measure = c("TTR", "CTTR", "K")) |
153 | 153 | #' |
154 | 154 | #' toks <- tokens(corpus_subset(data_corpus_inaugural, Year > 2000)) |
@@ -382,7 +382,7 @@ compute_lexdiv_dfm_stats <- function(x, measure = NULL, log.base = 10) { |
382 | 382 | #' @param MSTTR_segment a numeric value defining the size of the each segment |
383 | 383 | #' for the computation of the the Mean Segmental Type-Token Ratio (Johnson, 1944) |
384 | 384 | compute_lexdiv_tokens_stats <- function(x, measure = c("MATTR", "MSTTR"), |
385 | | - MATTR_window, MSTTR_segment) { |
| 385 | + MATTR_window, MSTTR_segment) { |
386 | 386 | measure <- match.arg(measure, several.ok = TRUE) |
387 | 387 | result <- data.frame(document = docnames(x), stringsAsFactors = FALSE) |
388 | 388 |
|
@@ -426,7 +426,7 @@ compute_mattr <- function(x, MATTR_window = 100L) { |
426 | 426 | x <- tokens_ngrams(x, n = MATTR_window, concatenator = " ") |
427 | 427 |
|
428 | 428 | # get a list of TTRs by document |
429 | | - temp <- lapply(as.list(x), function(y) textstat_lexdiv(dfm(y), "TTR")[["TTR"]]) |
| 429 | + temp <- lapply(as.list(x), function(y) textstat_lexdiv(dfm(tokens(y)), "TTR")[["TTR"]]) |
430 | 430 | result <- unlist(lapply(temp, mean)) |
431 | 431 | return(result) |
432 | 432 | } |
|
0 commit comments