From 44015e0d7d49a0d5d228d51fd5b1892aa1ddd30d Mon Sep 17 00:00:00 2001 From: chainsawriot Date: Mon, 17 May 2021 19:35:57 +0200 Subject: [PATCH] Fix a bug of wsi which may make word set with length less than n_topiclabel_words --- R/oolong_tm.R | 2 ++ 1 file changed, 2 insertions(+) diff --git a/R/oolong_tm.R b/R/oolong_tm.R index 44cd939..f832f5a 100644 --- a/R/oolong_tm.R +++ b/R/oolong_tm.R @@ -221,6 +221,8 @@ .slice_sample <- function(x, n_topiclabel_words, n_correct_ws) { res <- split(.safe_sample(x), ceiling(seq_along(x) / n_topiclabel_words)) names(res) <- NULL + ## Filter out things that are not of the length n_topiclabel_words to prevent .safe_sample below select the last one + res <- res[purrr::map_lgl(res, ~length(.) == n_topiclabel_words)] labels <- purrr::map_chr(res, ~(paste(., collapse = ", "))) .safe_sample(labels, n_correct_ws) }