tests/testthat/test_struc2cpos.R

library(RcppCWB)
use_tmp_registry()
testthat::context("struc2cpos")

test_that(
  "struc2cpos",
  {
    cpos <- cl_struc2cpos(
      corpus = "REUTERS",
      s_attribute = "places",
      registry = get_tmp_registry(),
      struc = 1L
    )
    expect_equal(cpos, c(92L, 535L))
  }
)

test_that(
  "struc_to_cpos",
  {
    cpos_old <- cl_struc2cpos(
      corpus = "REUTERS",
      s_attribute = "places",
      registry = get_tmp_registry(),
      struc = 1L
    )
    s <- s_attr(corpus = "REUTERS", s_attribute = "places", registry = get_tmp_registry())
    cpos_new <- struc_to_cpos(struc = 1L, s_attr = s)
    expect_identical(cpos_old, cpos_new)
  }
)

Try the RcppCWB package in your browser

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

RcppCWB documentation built on Sept. 24, 2024, 1:08 a.m.