/ コードセンチメント分析における/誤り - r、センチメント分析

rコードの感情分析のエラー - r、感情分析

私は感情をするためにコードをrで書くことを試みているつぶやきをエクスポートして分析することで分析するには、次のコードはツイートをクリーンアップしてセンチメントパッケージを呼び出し、スコアリングを実行して結果を返すことを想定しています。

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

ただし、次のようなエラーが表示され続けます。

score.sentiment(Datasetgaza $ text、pos.words、neg.words、.progress = "text")にエラーがあります。 未使用の引数(.progress = "text")

渡された引数は次のとおりです。 gaza.scores = score.sentiment(Datasetgaza $ text、pos.words、neg.words、.progress = "text")

コードを手伝っていただければ幸いです。

回答:

回答№1は0

あなたは「。」を逃しました。進歩の前に。 確かにこれが役立つでしょう。

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