나는 똑같은 것을 알아 내려고했습니다 : 키릴 문자 자료에 대한 감정 분석을하는 법. 당신이 훌륭한 syuzhet 꾸러미가 여전히 키릴 문자를 지원하지 않는다는 것이 옳은 동안, 나는 제리 리그에 syuzhet의 수정 된 버전을 사용할 수있었습니다! 여기에 제가 사용한 코드가 있습니다. nrc 메소드와 러시아어를 지정할 수도 있고, 사용자 정의 메소드를 사용하여 러시아어 사전을 제공 할 수도 있습니다.
희망이 도움이됩니다. 귀하의 마일리지가 다를 수 있습니다!
get_sentiment_rus <- function(char_v, method="custom", lexicon=NULL, path_to_tagger = NULL, cl = NULL, language = "english") {
language <- tolower(language)
russ.char.yes <- "[\u0401\u0410-\u044F\u0451]"
russ.char.no <- "[^\u0401\u0410-\u044F\u0451]"
if (is.na(pmatch(method, c("syuzhet", "afinn", "bing", "nrc",
"stanford", "custom"))))
stop("Invalid Method")
if (!is.character(char_v))
stop("Data must be a character vector.")
if (!is.null(cl) && !inherits(cl, "cluster"))
stop("Invalid Cluster")
if (method == "syuzhet") {
char_v <- gsub("-", "", char_v)
}
if (method == "afinn" || method == "bing" || method == "syuzhet") {
word_l <- strsplit(tolower(char_v), "[^A-Za-z']+")
if (is.null(cl)) {
result <- unlist(lapply(word_l, get_sent_values,
method))
}
else {
result <- unlist(parallel::parLapply(cl = cl, word_l,
get_sent_values, method))
}
}
else if (method == "nrc") {
# word_l <- strsplit(tolower(char_v), "[^A-Za-z']+")
word_l <- strsplit(tolower(char_v), paste0(russ.char.no, "+"), perl=T)
lexicon <- dplyr::filter_(syuzhet:::nrc, ~lang == tolower(language),
~sentiment %in% c("positive", "negative"))
lexicon[which(lexicon$sentiment == "negative"), "value"] <- -1
result <- unlist(lapply(word_l, get_sent_values, method,
lexicon))
}
else if (method == "custom") {
# word_l <- strsplit(tolower(char_v), "[^A-Za-z']+")
word_l <- strsplit(tolower(char_v), paste0(russ.char.no, "+"), perl=T)
result <- unlist(lapply(word_l, get_sent_values, method,
lexicon))
}
else if (method == "stanford") {
if (is.null(path_to_tagger))
stop("You must include a path to your installation of the coreNLP package. See http://nlp.stanford.edu/software/corenlp.shtml")
result <- get_stanford_sentiment(char_v, path_to_tagger)
}
return(result)
}
안녕하세요, 응답 해 주셔서 감사 드리며 코드를 공유해 주셔서 감사합니다. 질문을 게시 한 이래로 저는 여기서 약간의 진전을 이뤘습니다. 그리고 당신이 너무 친절하게 나눌 수있어서 기뻤습니다. 아마도 우리는 이메일로 연락 할 수 있습니다 - 나는 로버트 [도트] chestnutt2 [at] mail [dot] dcu [dot] ie에 있거나 더블린 시티 대학의 법과 정부 웹 사이트에서 내 연락처 정보를 얻을 수 있습니다. –