/ / błąd w analizie sentymentu kodu r - r, analiza sentymentu

błąd w analizie nastrojów r - r, analiza sentymentów

Próbuję napisać kod w r, aby zrobić sentymentanaliza poprzez eksportowanie i analizowanie tweetów, poniższy kod ma oczyścić tweet wywołujący pakiet sentymentów zrobić punktację i powrócić do wyniku, ten kod został cytowany w wielu blogach technicznych kod jest następujący:

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)
}

Mimo to otrzymuję następujący błąd:

Błąd w pliku score.sentiment (Datasetgaza $ text, pos.words, neg.words, .progress = "text"): nieużywany argument (.progress = "tekst")

Przekazano argument: gaza.scores = score.sentiment (Datasetgaza $ text, pos.words, neg.words, .progress = "text")

wszelka pomoc z kodem byłaby bardzo mile widziana

Odpowiedzi:

0 dla odpowiedzi № 1

Przegapiłeś „.” przed postępem. na pewno to pomoże.

    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)
}