Skip to content

Commit

Permalink
test for split() by s-attribute without values #263
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Blätte authored and Andreas Blätte committed Sep 7, 2023
1 parent 484007a commit 4b12314
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/testthat/test_split.R
Expand Up @@ -45,6 +45,34 @@ test_that(
pp1[["Angela Dorothea Merkel"]]@cpos,
pp3@cpos
)

# the following tests require that GERMAPARL2MINI is available
# It is wrapped into the GermaParl2 package, which can be installed as
# follows:
# install.packages(
# pkgs = "GermaParl2",
# contriburl = "https://polmine.github.io/drat/src/contrib",
# type = "source"
# )

skip_if_not(use("GermaParl2"))

gparl2 <- corpus("GERMAPARL2MINI")

renner <- gparl2 %>%
subset(speaker_who == "Renner")

n_subcorpora <- split(renner, s_attribute = "s", verbose = FALSE) |>
length()

n_sentences <- renner |>
slot("cpos") %>%
RcppCWB::ranges_to_cpos() %>%
RcppCWB::cl_cpos2struc(corpus = "GERMAPARL2MINI", s_attribute = "s", cpos = ., registry = gparl2@registry_dir) %>%
unique() %>%
length()

expect_identical(n_subcorpora, n_sentences)
}
)

0 comments on commit 4b12314

Please sign in to comment.