tests/testthat/test-stopwords.R

test_that("tokenize stopword works", {
  skip_if_offline()
  skip_on_os(os = "windows", arch = "i386")
  res <- tokenize("Test text.", stopwords = FALSE)
  expect_equal(nrow(res), 3)
  expect_true(res[nrow(res), "form"] == ".")
  res <- tokenize("Test text.", stopwords = TRUE)
  expect_equal(nrow(res), 2)
  expect_true(res[nrow(res), "form"] != ".")
})

test_that("stopwords works", {
  sw <- Stopwords$new()
  expect_equal(class(sw), c("Stopwords","R6"))
  expect_equal(nrow(sw$get()), 106)
  sw <- Stopwords$new(use_system_dict = F)
  expect_equal(nrow(sw$get()), 0)
  sw$add("dkdh")
  expect_equal(nrow(sw$get()), 1)
})

Try the elbird package in your browser

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

elbird documentation built on Aug. 12, 2022, 5:08 p.m.