tests/testthat/test-diagnosis.R

library(quanteda)
library(magrittr)
data(keyATM_data_bills)
bills_dfm <- keyATM_data_bills$doc_dfm
keyATM_docs <- keyATM_read(bills_dfm)

keywords <- list(Government     = c("laws", "law", "executive"),
                 Congress       = c("congress", "party"),
                 Peace          = c("world", "freedom"),
                 Constitution   = c("constitution"),
                 ForeignAffairs  = c("foreign", "war"))
out <- keyATM(docs = keyATM_docs, no_keyword_topics = 5, keywords = keywords,
  model = "base", options = list(seed = 250, iterations = 100))

test_that("Semantic coherence", {
  res <- semantic_coherence(out, keyATM_docs)
  skip_on_os(c("windows", "linux")) ; skip_on_cran()
  expect_equal(as.numeric(res[3]), -20.38699, tolerance = 0.0001)
})

Try the keyATM package in your browser

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

keyATM documentation built on April 3, 2025, 10:30 p.m.