tests/testthat/test-wordcount.R

context("Word counts")

dir <- system.file("extdata/legal", package = "textreuse")
corpus <- TextReuseCorpus(dir = dir)

test_that("counts words correctly for different classes", {
  w <- c("One two three four five six seven; all good children go to heaven.")
  expect_equal(wordcount(w), 13)
  w_doc <- TextReuseTextDocument(w, meta = list(id = "test"))
  expect_equal(wordcount(w), 13)
})

test_that("counts words for a corpus", {
  wc <- wordcount(corpus)
  expect_true(!is.null(names(wc)))
  wc <- unname(wc)
})

Try the textreuse package in your browser

Any scripts or data that you put into this service are public.

textreuse documentation built on July 8, 2020, 6:40 p.m.