2016-04-06 11 views
1

Tek bir sözcük yerine belirli cümlelerle (iki veya daha fazla sözcük birleştirilmiş) bir metinden bir TDM oluşturmak istiyorum. Cümleler, örneğin, "climate change", "global worming", "lad use", vb. Olabilir. Gördüğüm örnekler tek kelimeyle yazılmıştır.metin madenciliği R

tabela = DocumentTermMatrix(textolimpo, 
     list(dictionary = c("climate change","global worming","land use"))) 

Birisi bana yardım ederse minnettarım.

Şerefe.

Rafael

Ben quanteda tavsiye

cevap

2

:

library(quanteda) 
textolimpo <- c("This climate change concerns me. This climate changes", "Wormed: global worming increased") 
(dfm <- dfm(textolimpo, 
      ngrams=2L, 
      dictionary = list(climate="climate_change", 
          warm="global_worming"), 
      valuetype = "regex")) 
# 2 x 2 sparse Matrix of class "dfmSparse" 
#  features 
# docs climate warm 
# text1  2 0 
# text2  0 1 
(dfm <- dfm(textolimpo, 
      ngrams=2L, 
      thesaurus = list(climate="climate_change", 
          warm="global_worming"), 
      valuetype = "regex")) 
# 2 x 8 sparse Matrix of class "dfmSparse" 
#  this_climate change_concerns concerns_me me_this wormed_global worming_increased CLIMATE WARM 
# text1   2    1   1  1    0     0  2 0 
# text2   0    0   0  0    1     1  0 1 
+3

Tremors yaşananlar küresel worming nedir? – rawr

İlgili konular