2017-12-20 24 views
0

모든 해시 태그를 마이닝하여 트위터 데이터를 분석하려고합니다. 모든 해시 태그를 코퍼스에 넣고이 코퍼스를 단어 목록에 매핑하려고합니다. 이 문제를 어떻게 관리 할 수 ​​있는지 알고 있습니까? 여기 여기 해시 태그 (텍스트 마이닝)의 코퍼스를 구성하는 방법

내가 사용하는 코드는

내 데이터의 스냅하지만 난 여기

step1 <- strsplit(newFile$Hashtag, "#") 
step2 <- lapply(step1, tail, -1) 
result <- lapply(step2, function(x){ 
sapply(strsplit(x, " "), head, 1) 
}) 
result2<-do.call(c, unlist(result, recursive=FALSE)) 
myCorpus <- tm::Corpus(VectorSource(result2)) # create a corpus 

정보에 관한 희소성의 100 % 내 DTM에 문제가 내 코퍼스

myCorpus 
    <<SimpleCorpus>> 
Metadata: corpus specific: 1, document level (indexed): 0 
Content: documents: 12635 

그리고 내 DTM

<<DocumentTermMatrix (documents: 12635, terms: 6280)>> 
Non-/sparse entries: 12285/79335515 
Sparsity   : 100% 
Maximal term length: 36 
Weighting   : term frequency (tf) 
+0

에 오신 것을 환영합니다 SO가. 사진은 이미지 처리시 Q가 아니면 코드 또는 데이터가 아닙니다. 당신은 질문을 할 때 지침을 가지고 있었고, 그래서 괜찮은 질문을하는 법을 가르쳐주었습니다. 우리는 당신이 트위터 검색 방법/방법을 모릅니다. 따라서 쿼리의 경우 해시 태그가 희소 할 수 있습니다. 또한 해시 태그 "구문 분석"은 [그보다 복잡합니다] (https://stackoverflow.com/a/38789142/1457051) – hrbrmstr

답변

0

귀하의 문제는 str_split입니다. 당신이 시도해야합니다

str_extract_all("This all are hashtag #hello #I #am #a #buch #of #hashtags", "#\\S+")

As results this list: 
[[1]] 
[1] "#hello" "#I"  "#am"  "#a"  "#buch"  "#of"  
[7] "#hashtags" 

를 원하는 결과가 데이터 프레임을 사용 simplify = T 경우 : 결과

str_extract_all("This all are hashtag #hello #I #am #a #buch #of #hashtags", "#\\S+", simplify = T) 

:

 [,1]  [,2] [,3] [,4] [,5] [,6] [,7]  
[1,] "#hello" "#I" "#am" "#a" "#buch" "#of" "#hashtags"