|
|
|
@ -35,7 +35,7 @@ dfm_gen <- function(out,words = '999', text = c("lemmas","full")) {
|
|
|
|
|
str_replace_all("<.*?>", " ") %>%
|
|
|
|
|
str_replace_all("\\s+"," ")
|
|
|
|
|
}
|
|
|
|
|
# out$codes <- out$`_source.codes.majorTopic` %>%
|
|
|
|
|
if ('_source.codes.majorTopic' %in% colnames(out)) {
|
|
|
|
|
out <- out %>%
|
|
|
|
|
mutate(codes = case_when(
|
|
|
|
|
.$`_source.codes.timeSpent` == -1 ~ NA_character_,
|
|
|
|
@ -56,7 +56,11 @@ dfm_gen <- function(out,words = '999', text = c("lemmas","full")) {
|
|
|
|
|
.[,2] %>%
|
|
|
|
|
as.numeric()
|
|
|
|
|
)
|
|
|
|
|
dfm <- corpus(out$merged, docnames = out$`_id`, docvars = out[,-seq(1,(length(names(out))-3),1)]) %>%
|
|
|
|
|
vardoc <- out[,-seq(1,(length(names(out))-3),1)]
|
|
|
|
|
} else {
|
|
|
|
|
vardoc <- NULL
|
|
|
|
|
}
|
|
|
|
|
dfm <- corpus(out$merged, docnames = out$`_id`, docvars = vardoc) %>%
|
|
|
|
|
dfm(tolower = T, stem = F, remove_punct = T, valuetype = "regex", ngrams = 1)
|
|
|
|
|
return(dfm)
|
|
|
|
|
}
|
|
|
|
|