From e499d70671fbcc73102ce81907f02e03877cf0bb Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 27 May 2020 13:13:21 +0200 Subject: [PATCH] actor_merger: added ungroup() calls at the start and end of function, to speed up processing sentencizer: added ungroup() call at the end of the function to speed up processing --- R/actor_merger.R | 4 +++- R/sentencizer.R | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/R/actor_merger.R b/R/actor_merger.R index e45f5e5..21af375 100644 --- a/R/actor_merger.R +++ b/R/actor_merger.R @@ -37,6 +37,7 @@ actor_merger <- function(df, actors_meta, ids = NULL) { text_sent <- df %>% select(`_id`,starts_with("text."),-ends_with("sent_lemmas")) df <- df %>% + ungroup() %>% select(-ends_with("sent_lemmas"),-starts_with("text.")) %>% unnest(cols = colnames(.)) ## Unnest to sentence level @@ -170,7 +171,8 @@ actor_merger <- function(df, actors_meta, ids = NULL) { yearmonth = strftime(publication_date, format = '%Y%m'), yearmonthday = strftime(publication_date, format = '%Y%m%d'), yearweek = strftime(publication_date, format = "%Y%V") - ) + ) %>% + ungroup() return(df) } } diff --git a/R/sentencizer.R b/R/sentencizer.R index cf523b6..85747d7 100644 --- a/R/sentencizer.R +++ b/R/sentencizer.R @@ -126,7 +126,8 @@ sentencizer <- function(out, sent_dict = NULL, localhost = NULL, validation = F) out <- out %>% summarise_all(list) %>% left_join(.,text_sent,by='_id') %>% - left_join(.,metadata,by='_id') + left_join(.,metadata,by='_id') %>% + ungroup() return(out) } saveRDS(par_sent(1:nrow(out),out = out, sent_dict=sent_dict), file = paste0('df_out',as.numeric(as.POSIXct(Sys.time())),'.Rds'))