感情分析のためにつぶやきを並べ替えるために、絵文字を処理/取り除くにはどうすればよいですか?Twitterでの絵文字rの感情分析
行き方:sort.listで エラー(Y): 無効な入力
おかげ
をして、これは顔文字は、Twitterからとrに探して出てくる方法です:
\xed��\xed�\u0083\xed��\xed��
\xed��\xed�\u008d\xed��\xed�\u0089
感情分析のためにつぶやきを並べ替えるために、絵文字を処理/取り除くにはどうすればよいですか?Twitterでの絵文字rの感情分析
行き方:sort.listで エラー(Y): 無効な入力
おかげ
をして、これは顔文字は、Twitterからとrに探して出てくる方法です:
\xed��\xed�\u0083\xed��\xed��
\xed��\xed�\u008d\xed��\xed�\u0089
これは、ndooganによって提案されたiconv
を使用して、顔文字を取り除くべきです。
いくつかの再現性のあるデータ:
require(twitteR)
# note that I had to register my twitter credentials first
# here's the method: http://stackoverflow.com/q/9916283/1036500
s <- searchTwitter('#emoticons', cainfo="cacert.pem")
# convert to data frame
df <- do.call("rbind", lapply(s, as.data.frame))
# inspect, yes there are some odd characters in row five
head(df)
text
1 ROFLOL: echte #emoticons [humor] http://t.co/0d6fA7RJsY via @tweetsmania ;-)
2 “@teeLARGE: when tmobile get the iphone in 2 wks im killin everybody w/ emoticons & \nall the other stuff i cant see on android!" \n#Emoticons
3 E poi ricevi dei messaggi del genere da tua mamma xD #crazymum #iloveyou #emoticons #aiutooo #bestlike http://t.co/Yee1LB9ZQa
4 #emoticons I want to change my name to an #emoticon. Is it too soon? #prince http://t.co/AgmR5Lnhrk
5 I use emoticons too much. #addicted #admittingit #emoticons <ed><U+00A0><U+00BD><ed><U+00B8><U+00AC><ed><U+00A0><U+00BD><ed><U+00B8><U+0081> haha
6 What you text What I see #Emoticons http://t.co/BKowBSLJ0s
ここで顔文字を削除しますキーラインです:今
# Clean text to remove odd characters
df$text <- sapply(df$text,function(row) iconv(row, "latin1", "ASCII", sub=""))
は(行5を参照してください奇妙な文字がなくなっているかどうかを確認するために、もう一度点検します)
head(df)
text
1 ROFLOL: echte #emoticons [humor] http://t.co/0d6fA7RJsY via @tweetsmania ;-)
2 @teeLARGE: when tmobile get the iphone in 2 wks im killin everybody w/ emoticons & \nall the other stuff i cant see on android!" \n#Emoticons
3 E poi ricevi dei messaggi del genere da tua mamma xD #crazymum #iloveyou #emoticons #aiutooo #bestlike http://t.co/Yee1LB9ZQa
4 #emoticons I want to change my name to an #emoticon. Is it too soon? #prince http://t.co/AgmR5Lnhrk
5 I use emoticons too much. #addicted #admittingit #emoticons haha
6 What you text What I see #Emoticons http://t.co/BKowBSLJ0s
正規表現を使用してct非アルファベット文字を削除して削除します。サンプルコード:
rmNonAlphabet <- function(str) {
words <- unlist(strsplit(str, " "))
in.alphabet <- grep(words, pattern = "[a-z|0-9]", ignore.case = T)
nice.str <- paste(words[in.alphabet], collapse = " ")
nice.str
}
は(iconvをして作業してみてください) – ndoogan
そしてEncodings' –
'を見て、私はあなたがこれらのエンコーディングは何を意味するのかを把握示唆するかもしれません?。顔文字は、正式なテキスト言語では捕捉できない意味を伝える言語の一種です。あなたが何をしているのかはっきりしていませんが、これらの顔文字は、典型的な形式的言語が余裕がないような方法でジェスチャー/表情を表現する感情です。顔文字を削除するのではなく、その絵文字がどのような意味を伝えているかを把握するために、コメント/解決法をここでも使用してください。 –