tests/testthat/test-data.R

context("test data objects")

test_that("corpus data objects contain expected quantities", {
    expected_user_fields <- c("description", "source", "url", "author", "keywords", "title")
    expected_system_fields <- "summary"

    expect_true(all(expected_user_fields %in% names(quanteda::meta(data_corpus_irishbudget2010, type = "user"))))
    expect_true(all(expected_system_fields %in% names(quanteda::meta(data_corpus_irishbudget2010, type = "system"))))

    expect_true(all(expected_user_fields %in% names(quanteda::meta(data_corpus_dailnoconf1991, type = "user"))))
    expect_true(all(expected_system_fields %in% names(quanteda::meta(data_corpus_dailnoconf1991, type = "system"))))

    expect_true(all(expected_user_fields %in% names(quanteda::meta(data_corpus_EPcoaldebate, type = "user"))))
    expect_true(all(expected_system_fields %in% names(quanteda::meta(data_corpus_EPcoaldebate, type = "system"))))

    expect_true(all(expected_user_fields %in% names(quanteda::meta(data_corpus_moviereviews, type = "user"))))
    expect_true(all(expected_system_fields %in% names(quanteda::meta(data_corpus_moviereviews, type = "system"))))

    expect_identical(class(data_corpus_irishbudget2010), c("corpus", "character"))
    expect_identical(class(data_corpus_dailnoconf1991), c("corpus", "character"))
    expect_identical(class(data_corpus_EPcoaldebate), c("corpus", "character"))
    expect_identical(class(data_corpus_moviereviews), c("corpus", "character"))
})

Try the quanteda.textmodels package in your browser

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

quanteda.textmodels documentation built on Sept. 11, 2024, 8:19 p.m.