bit2r / bitTA

기능이 bitNLP로 이관되었습니다. bitNLP를 사용하시기 바랍니다.
https://r2bit.com/bitNLP/
GNU General Public License v2.0
10 stars 0 forks source link

RStudio Cloud 오류 건 #32

Closed choonghyunryu closed 1 year ago

choonghyunryu commented 1 year ago

문제의 현상

RStudio Cloud 무료 환경은 CPU 자원에서 Core 1개만 지원합니다. 관련되어 다음과 같은 오류가 발생합니다.

이것은 unnest_noun_ngrams() 함수에서 호출하는 tokenize_noun_ngrams() 함수에서, 내부적으로 사용되는 collapse_noun()가

> 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() 함수를 수정하려 합니다.

choonghyunryu commented 1 year ago

개발버전인 1.3.3.9000에서 구현 완료