From 26b77d97fcd560f6c4aadbf82188cec9a956d281 Mon Sep 17 00:00:00 2001 From: Kenneth Benoit Date: Mon, 16 Oct 2023 18:36:25 +0100 Subject: [PATCH] Fix deprecated usages .Rbuildignore .github --- .Rbuildignore | 1 + R/crossval.R | 3 ++- man/crossval.Rd | 3 ++- tests/testthat/test-textmodel_cnnlstmemb.R | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.Rbuildignore b/.Rbuildignore index c1ab8f3..eaf3879 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -5,3 +5,4 @@ ^\.Rproj\.user$ README.Rmd tests/misc/ +\.github/ \ No newline at end of file diff --git a/R/crossval.R b/R/crossval.R index 2874048..24037ef 100644 --- a/R/crossval.R +++ b/R/crossval.R @@ -9,7 +9,8 @@ #' @examples #' library("quanteda") #' library("quanteda.textmodels") -#' dfmat <- dfm(data_corpus_moviereviews) +#' dfmat <- tokens(data_corpus_moviereviews) |> +#' dfm() #' tmod <- textmodel_nb(dfmat, y = data_corpus_moviereviews$sentiment) #' crossval(tmod, k = 5, by_class = TRUE) #' crossval(tmod, k = 5, by_class = FALSE) diff --git a/man/crossval.Rd b/man/crossval.Rd index 6300f15..10e1449 100644 --- a/man/crossval.Rd +++ b/man/crossval.Rd @@ -22,7 +22,8 @@ Cross-validate a fitted textmodel using \emph{k}-fold cross-validation. \examples{ library("quanteda") library("quanteda.textmodels") -dfmat <- dfm(data_corpus_moviereviews) +dfmat <- tokens(data_corpus_moviereviews) |> + dfm() tmod <- textmodel_nb(dfmat, y = data_corpus_moviereviews$sentiment) crossval(tmod, k = 5, by_class = TRUE) crossval(tmod, k = 5, by_class = FALSE) diff --git a/tests/testthat/test-textmodel_cnnlstmemb.R b/tests/testthat/test-textmodel_cnnlstmemb.R index 5ca91de..5298b04 100644 --- a/tests/testthat/test-textmodel_cnnlstmemb.R +++ b/tests/testthat/test-textmodel_cnnlstmemb.R @@ -7,7 +7,7 @@ test_that("the cnnlstmemb model works", { subset = language == "English") %>% corpus_sample(500) - toks <- tokens(texts(corp)) + toks <- tokens(corp) label <- ifelse(docvars(corp, "crowd_subsidy_label") == "Pro-Subsidy", 1, 0) tmod <- textmodel_cnnlstmemb(toks, y = label, epochs = 8)