SentimentAnalysis: SentimentAnalysis

Usage Arguments Examples

View source: R/SentimentAnalysis.R

Usage

1

Arguments

Dat

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (Dat) 
{
    cat("\n")
    profile_emot <- matrix(rep(0, length(Dat$filename) * 10), 
        ncol = 10)
    for (i in 1:length(Dat$filename)) {
        profile_emot[i, ] <- get_nrc_values(get_tokens(Dat$text[i]))/length(get_tokens(Dat$text[i]))
        centex <- centerText_2(paste(Dat$profname, " Sentiment Analysis >>>>>>>>>>  ", 
            round(i/length(Dat$filename) * 100, 2), "%", "  >>>>>>>>>>>>>>>>>"))
        cat("\r", centex$mid)
        Sys.sleep(0.2)
    }
    cat("\n")
    cat(" Writing Output ", "\n")
    Emot_Mat <- cbind(filename = Dat$filename, profile_emot)
    colnames(Emot_Mat) <- c("filename", names(get_nrc_values("joy")))
    write.csv(Emot_Mat, paste0(Dat$profname, "_emot.csv"))
    invisible(return(Emot_Mat))
  }

pingqingsheng/Robot0001 documentation built on May 5, 2019, 5:53 p.m.