tests/testthat/test_arguments.R

context("Arguments Check")
library(textwhiz)

df = data.frame(text_id = c(1:3),
                text = c("the seahawks are my favorite team.",
                         "russel wilson should be an mvp",
                         "seattle are superbowl champions"
                ),
                labels = c("nfl",
                           "nfl",
                           "nfl"
                ))

missing_dim <- expand.grid(
  lr = seq(4, 4.3, 0.5),
  epoch = seq(30, 33, 10),
  ws = seq(4, 6, 2),
  wordNgrams = 2,
  minn = 2,
  maxn = 6
)

test_that("'parameters' argument check", {
  expect_error(tune_fasttext(k = 3,
                             texts = df$text,
                             text_ids = df$text_id,
                             labels = df$labels,
                             parameters = missing_dim))
  expect_error(forensic_fasttext(k = 3,
                                 texts = df$text,
                                 text_ids = df$text_id,
                                 labels = df$labels,
                                 parameters = missing_dim))
})
jcgonzalez14/textwhiz documentation built on Aug. 26, 2020, 9:39 a.m.