0

I'm trying to implement a sentiment analysis study on data extracted from Twitter, with R. I am using the udpipe library when I write

udpipe_dowload_model("model")
model< <- udpipe_load_model("directory)
out <- as.data.frame(udpipe_annotate(object, x, doc_id,...)

and I run, an exception is raised:

Error in udp_tokenise_tag_parse(object$model, x, doc_id, tokenizer, tagger,  : 
  external pointer is not valid 

the relative traceback is:

4.
stop(structure(list(message = "external pointer is not valid", 
    call = udp_tokenise_tag_parse(object$model, x, doc_id, tokenizer, 
        tagger, parser, log_every, log_now), cppstack = structure(list(
        file = "", line = -1L, stack = c("1   udpipe.so                           0x0000000117ba907e _ZN4Rcpp9exceptionC2EPKcb + 222",  ... 
3.
udp_tokenise_tag_parse(object$model, x, doc_id, tokenizer, tagger, 
    parser, log_every, log_now) 
2.
udpipe_annotate(model, x = x, doc_id = doc_id, trace = F) at textAnalysisFunct.R#221
1.
lemmaUDP(x = twt$text_clean, model = modelI, doc_id = twt$doc_id, 
    stopw = tm::stopwords("italian"), userstopw = mystop) 

then I started to debug and on the console appeared:

Error during wrapup: external pointer is not valid

the function lemmaUDP was created by my teacher, if useful I paste here its definition as well, but is the same as if done manually

lemmaUDP <- function(x = NULL, 
                     model = NULL, 
                     doc_id = NULL, 
                     stopw = tm::stopwords("italian"), 
                     userstopw=NULL){

  require(udpipe)
  if(is.null(x)){message("manca vettore testi");return()}
  if(is.null(model)){message("manca modello");return()}
  if(class(x) != "character"){message("il vettore x non è di tipo testo");return()}
  if(class(model) != "udpipe_model"){message("modello non valido");return()}
  if(is.null(doc_id)){doc_id <- 1:length(x)}
  if(!is.null(userstopw)){
    stopw <- c(stopw,userstopw)
  }
  xx <- udpipe_annotate(model, x = x, doc_id = doc_id,trace = F)
  xx <- as.data.frame(xx)
  xx$STOP <- ifelse(xx$lemma %in% stopw | xx$token %in% stopw,TRUE,FALSE)
  return(xx)
}
Phil
  • 7,287
  • 3
  • 36
  • 66
  • looks like you are storing the udpipe model in the model object but when you call `udpipe_annotate`, you use object instead of model. – phiver May 06 '21 at 10:00
  • I browsed on the internet and I found some other people who encountered the same problem. it appears to be regarding the pointer used to get to the memory address of the file in which the model is contained. once you close the session and reopen it, the pointer used to identify the model address is gone. I had to download the model again in a new session to fix this. – Lorenzo Consoli May 06 '21 at 21:31

0 Answers0