tests/testthat/test-grow.R

context("Test grow (ensure that grow() still work)")

toks <- ECB_press_conferences_tokens[1:10]

test_that("LDA works", {
  expect_silent(LDA <- grow(LDA(toks), 10, displayProgress = FALSE))
  expect_output(
    print(LDA),
    "An LDA model with 5 topics. Currently fitted by 10 Gibbs sampling iterations."
  )
})


test_that("rJST works", {
  expect_silent(
    rJST <- grow(
      rJST(toks, lexicon = LoughranMcDonald),
      10,
      displayProgress = FALSE
    )
  )
  expect_output(
    print(rJST),
    "A reverse-JST model with 5 topics and 3 sentiments. Currently fitted by 10 Gibbs sampling iterations."
  )
})


test_that("JST works", {
  expect_silent(
    JST <- grow(
      JST(toks, lexicon = LoughranMcDonald),
      10,
      displayProgress = FALSE
    )
  )
  expect_output(
    print(JST),
    "A JST model with 3 sentiments and 5 topics. Currently fitted by 10 Gibbs sampling iterations."
  )
})


test_that("sentopicsmodel works", {
  expect_silent(
    sentopicsmodel <- grow(
      sentopicsmodel(toks, lexicon = LoughranMcDonald),
      10,
      displayProgress = FALSE
    )
  )
  expect_output(
    print(sentopicsmodel),
    "A sentopicsmodel topic model with 5 topics and 3 sentiments. Currently fitted by 10 Gibbs sampling iterations."
  )
})

Try the sentopics package in your browser

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

sentopics documentation built on Sept. 10, 2026, 5:10 p.m.