RStudio Cloud 무료 환경은 CPU 자원에서 Core 1개만 지원합니다.
관련되어 다음과 같은 오류가 발생합니다.
이것은 unnest_noun_ngrams() 함수에서 호출하는 tokenize_noun_ngrams() 함수에서, 내부적으로 사용되는 collapse_noun()가
Windows인 경우에는 싱글 코어만 지원하게 예외처리되고,
타 운영체제에서는 멀티코어를 사용하게 처리되면서 발생하는 에러입니다.
> dtm_envir <- president_speech %>%
+ filter(category %in% "환경") %>%
+ unnest_noun_ngrams(term, doc, n = 1) %>%
+ filter(!str_detect(term, "[[a-zA-Z]]+")) %>% ## 영문자를 제거함
+ count(id, term, sort = TRUE) %>%
+ cast_dtm(id, term, n)
Error in `tidytext::unnest_tokens()`:
! Expected output of tokenizing function to be a list of length 25
Run `rlang::last_error()` to see where the error occurred.
Warning message:
In parallel::mclapply(seq(chunk_idx$idx_start), get_collapse_noun, :
all scheduled cores encountered errors in user code
문제의 해결
RStudio Cloud 환경에서 1개의 코어를 사용하지만 다음의 parallel::detectCores()를 보면 16개로 인식되었습니다.
> parallel::detectCores()
[1] 16
그래서 parallel::detectCores()를 호출해서 예외처리할 수는 없을 것 같고,
tokenize_noun_ngrams() 함수에 mc.cores 인수를 추가헤서,
무료 RStudio Cloud 환경에서는 mc.cores의 값을 1로 지정해서 에러를 회피하도록,
tokenize_noun_ngrams() 함수를 수정하려 합니다.
문제의 현상
RStudio Cloud 무료 환경은 CPU 자원에서 Core 1개만 지원합니다. 관련되어 다음과 같은 오류가 발생합니다.
이것은 unnest_noun_ngrams() 함수에서 호출하는 tokenize_noun_ngrams() 함수에서, 내부적으로 사용되는 collapse_noun()가
문제의 해결
RStudio Cloud 환경에서 1개의 코어를 사용하지만 다음의 parallel::detectCores()를 보면 16개로 인식되었습니다.
그래서 parallel::detectCores()를 호출해서 예외처리할 수는 없을 것 같고, tokenize_noun_ngrams() 함수에 mc.cores 인수를 추가헤서,
무료 RStudio Cloud 환경에서는 mc.cores의 값을 1로 지정해서 에러를 회피하도록, tokenize_noun_ngrams() 함수를 수정하려 합니다.