2013-04-01 2 views
17

정서 분석을 위해 트윗을 분류 할 수 있도록 이모티콘을 어떻게 처리합니까?이모티콘 트위터의 센티멘트 분석

방법 : 오류를 sort.list에 (Y) : 잘못된 입력

감사

이는 이모티콘이 트위터에서와 R에보고 나올 방법은 다음과 같습니다

\xed��\xed�\u0083\xed��\xed�� 
\xed��\xed�\u008d\xed��\xed�\u0089 
+3

가의 iconv()로 – ndoogan

+0

작업을 시도하고 볼'Encodings' –

+1

난 당신이 이러한 인코딩이 무엇을 의미하는지 알아 제안 할 수 있습니까?가. 이모티콘은 공식 텍스트 언어로 캡처되지 않을 수도있는 의미를 전달하는 언어의 한 형태입니다. 당신이 뭘하고 있는지 모르지만이 이모티콘은 전형적인 형식 언어가 감당할 수없는 방식으로 제스쳐/얼굴 표정을 표현하는 정서입니다. 이모티콘을 없애기 위해서가 아니라 이모티콘에 의해 어떤 의미가 전달되는지 알아 내려고 여기에서 코멘트/솔루션을 사용하십시오. –

답변

20

이것은 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 &amp; \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 &amp; \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 
+0

벤 - 정말 고마워 - 청소 했어 - 마침내! – Rhodo

+0

당신을 환영합니다! 당신이 익숙하지 않은 경우에는 대답이 유용 할 경우 upvote해야합니다 (감사의 말을 듣는 것이 좋습니다). 위/아래 화살표 아래에있는 틱을 클릭하여 자신의 질문에 대한 답변이 가장 잘되었음을 나타냅니다. 문제. 그것은 당신과 같은 질문을 가진 다른 사람들에게 도움이 될 것입니다. (이 과정은 여러 답이있을 때 더 관련이 있습니다.이 경우에는 재미가 더 많습니다.) – Ben

+0

다시 한번 감사드립니다. 나는 15 초 upvote가 필요한 초보자입니다. – Rhodo

0

정규 표현식을 사용하면 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 
} 
관련 문제