/ / Fehler in der R-Code-Sentiment-Analyse - R, Sentiment-Analyse

Fehler in der r-Code-Sentiment-Analyse - r, Sentiment-Analyse

Ich versuche, einen Code in r zu schreiben, um Gefühle zu erzeugenAnalyse durch Exportieren und Analysieren von Tweets: Der folgende Code soll den Tweet bereinigen. Das Sentiment-Paket aufrufen, das Scoring durchführen und das Ergebnis zurückgeben. Dieser Code wurde in vielen technischen Blogs zitiert. Der Code lautet wie folgt:

score.sentiment = function(sentences , pos.words, neg.words , progress="none")
{
require(plyr)
require(stringr)
scores = laply(sentences,function(sentence,pos.words,neg.words)
{
sentence =gsub("[[:punct:]]","",sentence)
sentence =gsub("[[:cntrl]]","",sentence)
sentence =gsub("\d+","",sentence)
sentence=tolower(sentence)
word.list=str_split(sentence,"\s+")
words=unlist(word.list)
pos.matches=match(words,pos.words)
neg.matches=match(words,neg.words)
score=sum(pos.matches)-sum(neg.matches)
return(score)
},pos.words,neg.words,.progress=.progress)
scores.df=data.frame(scores=scores,text=sentences)
return(scores.df)
}

Ich bekomme jedoch weiterhin den folgenden Fehler:

Fehler in score.sentiment (Datasetgaza $ text, pos.words, neg.words, .progress = "text"): nicht verwendetes Argument (.progress = "text")

Das Argument bestand: gaza.scores = score.sentiment (Datasetgaza $ text, pos.words, neg.words, .progress = "text")

Jede Hilfe mit dem Code wäre sehr dankbar

Antworten:

0 für die Antwort № 1

Sie haben ein "." vor dem Fortschritt. Sicher wird das helfen.

    score.sentiment = function(sentences , pos.words, neg.words , .progress="none")
{
require(plyr)
require(stringr)
scores = laply(sentences,function(sentence,pos.words,neg.words)
{
sentence =gsub("[[:punct:]]","",sentence)
sentence =gsub("[[:cntrl]]","",sentence)
sentence =gsub("\d+","",sentence)
sentence=tolower(sentence)
word.list=str_split(sentence,"\s+")
words=unlist(word.list)
pos.matches=match(words,pos.words)
neg.matches=match(words,neg.words)
score=sum(pos.matches)-sum(neg.matches)
return(score)
},pos.words,neg.words,.progress=.progress)
scores.df=data.frame(scores=scores,text=sentences)
return(scores.df)
}