Error in simple_triplet_matrix - it is impossible to use RWeka to count phrases

Using TM, I compare DocumentTermMatrix with a list of dictionaries for counting:

totals <- inspect(DocumentTermMatrix(x, list(dictionary = d)))

This works fine for single words, but I want to include double words and cannot figure out how to do this.

I tried RWeka:

TrigramTokenizer <- function(x) NGramTokenizer(x, 
                                               Weka_control(min = 3, max = 3))
tdm <- TermDocumentMatrix(v.corpus, 
                          control = list(tokenize = TrigramTokenizer))

BUt will receive the following error message:

Error in simple_triplet_matrix(i = i, j = j, v = as.numeric(v), nrow = length(allTerms),  : 
  'i, j, v' different lengths
In addition: Warning messages:
1: In parallel::mclapply(x, termFreq, control) :
  all scheduled cores encountered errors in user code
2: In is.na(x) : is.na() applied to non-(list or vector) of type 'NULL'
3: In simple_triplet_matrix(i = i, j = j, v = as.numeric(v), nrow = length(allTerms),  :
  NAs introduced by coercion.

Can you help with the error message?

Thanks!!

+4
source share
1 answer

See my answer here

There seems to be problems using RWeka with the parallel package . I found a workaround here.

1: http://r.789695.n4.nabble.com/RWeka-and-multicore-package-td4678473.html#a4678948

RWeka .

,

BigramTokenizer <- function(x) {RWeka::NGramTokenizer(x, RWeka::Weka_control(min = 2, max = 2))}
+2

All Articles