2017-12-20 7 views
0

すべてのハッシュタグをマイニングしてTwitterデータを分析しようとしています。私はすべてのハッシュタグをコーパスに入れ、このコーパスを単語のリストにマッピングしたいと思います。この問題をどうやって管理できるか考えていますか? は、ここに私のデータのスナップはハッシュタグ(テキストマイニング)のコーパスを構築する方法

ここで私が使用されるが、私はここでスパース

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" 
関連する問題