tests/testthat/test-nscrabble.R

test_that("test nscrabble", {
    txt1 <- c("muzjiks", "excellency", "")
    txt2 <- c(d1 = "muzjiks", d2 = "excellency", d3 = "")

    expect_identical(nscrabble(txt1), c(29L, 24L, NA))
    expect_identical(nscrabble(txt2), c(d1 = 29L, d2 = 24L, d3 = NA))

    txt3 <- "muzjiks excellency "
    expect_identical(
        nscrabble(txt3, FUN = sum),
        53L
    )
    expect_identical(
        nscrabble("xyz", FUN = min),
        4L
    )
    expect_equal(
        nscrabble("xyz", FUN = mean),
        7.333,
        tol = .001
    )

    # with names
    expect_identical(
        nscrabble(c(d1 = "xyz")),
        c(d1 = 22L)
    )
})

Try the quanteda.textstats package in your browser

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

quanteda.textstats documentation built on Nov. 2, 2023, 5:07 p.m.