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
master
Your Name 5 years ago
parent 8634d549a3
commit e499d70671

@ -37,6 +37,7 @@ actor_merger <- function(df, actors_meta, ids = NULL) {
text_sent <- df %>% text_sent <- df %>%
select(`_id`,starts_with("text."),-ends_with("sent_lemmas")) select(`_id`,starts_with("text."),-ends_with("sent_lemmas"))
df <- df %>% df <- df %>%
ungroup() %>%
select(-ends_with("sent_lemmas"),-starts_with("text.")) %>% select(-ends_with("sent_lemmas"),-starts_with("text.")) %>%
unnest(cols = colnames(.)) ## Unnest to sentence level 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'), yearmonth = strftime(publication_date, format = '%Y%m'),
yearmonthday = strftime(publication_date, format = '%Y%m%d'), yearmonthday = strftime(publication_date, format = '%Y%m%d'),
yearweek = strftime(publication_date, format = "%Y%V") yearweek = strftime(publication_date, format = "%Y%V")
) ) %>%
ungroup()
return(df) return(df)
} }
} }

@ -126,7 +126,8 @@ sentencizer <- function(out, sent_dict = NULL, localhost = NULL, validation = F)
out <- out %>% out <- out %>%
summarise_all(list) %>% summarise_all(list) %>%
left_join(.,text_sent,by='_id') %>% left_join(.,text_sent,by='_id') %>%
left_join(.,metadata,by='_id') left_join(.,metadata,by='_id') %>%
ungroup()
return(out) 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')) saveRDS(par_sent(1:nrow(out),out = out, sent_dict=sent_dict), file = paste0('df_out',as.numeric(as.POSIXct(Sys.time())),'.Rds'))

Loading…
Cancel
Save