bnosac / pattern.nlp

R package to perform sentiment analysis and Parts of Speech tagging for Dutch/French/English/German/Spanish/Italian
Other
67 stars 17 forks source link

Cannot use := to add columns to a null data.table (no columns), #11

Closed hack-r closed 5 years ago

hack-r commented 5 years ago

What sets this off?

Some of values in the input character vector may be empty, is that not allowed?

pos_tags.q2 <- mapply(article.id = 1:length(text.q2.clean), content = text.q2.clean, FUN=function(article.id, content){
  +   out            <- (x = content, language = "english", core = TRUE)
  +   out$article.id <- rep(article.id, times = nrow(out))
  +   out
  + }, SIMPLIFY = FALSE)
Hide Traceback

Rerun with Debug
Error in `[<-.data.table`(x, j = name, value = value) : 
  Cannot use := to add columns to a null data.table (no columns), currently. You can use := to add (empty) columns to a 0-row data.table (1 or more empty columns), though. 
6.
`[<-.data.table`(x, j = name, value = value) 
5.
`$<-.data.table`(`*tmp*`, "word.id", value = integer(0)) 
4.
`$<-`(`*tmp*`, "word.id", value = integer(0)) 
3.
pattern_pos(x = content, language = "english", core = TRUE) 
2.
(function (article.id, content) 
{
  out <- pattern_pos(x = content, language = "english", core = TRUE)
  out$article.id <- rep(article.id, times = nrow(out)) ... 
  1.
  mapply(article.id = 1:length(text.q2.clean), content = text.q2.clean, 
         FUN = function(article.id, content) {
           out <- pattern_pos(x = content, language = "english", 
                              core = TRUE) ... 
hack-r commented 5 years ago

I have determined that this is caused by empty strings. It would be nice to add some handling for this.

hack-r commented 5 years ago

CLARIFICATION:

It turns out that the specific culprit is " " not "". Just FYI. I may do a pull request to give you some handling for this R-Python mapping.