wrathematics / ngram

Fast n-Gram Tokenization
Other
71 stars 23 forks source link

Error when running example #1

Closed SteveBronder closed 9 years ago

SteveBronder commented 9 years ago

Is the package currently being reworked? It seems one of the external pointers is not being set.

library(ngram)
x <- "a b a c a b b"
ng <- ngram(x,n=3)
Error in validObject(.Object) : 
  invalid class “ngram” object: invalid object for slot "ngl_ptr" in class "ngram": 
  got class "NULL", should be or extend class "externalptr"

below is my session info

sessionInfo() R version 3.1.3 (2015-03-09) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 7 x64 (build 7601) Service Pack 1

locale: [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] ngram_2.0 devtools_1.8.0 slam_0.1-32 data.table_1.9.4 tm_0.6-1 NLP_0.1-7

loaded via a namespace (and not attached): [1] chron_2.3-45 curl_0.8 digest_0.6.8 git2r_0.10.1 memoise_0.2.1 parallel_3.1.3 plyr_1.8.2 Rcpp_0.11.6 reshape2_1.4.1 [10] rversions_1.0.1 stringr_0.6.2 tools_3.1.3 xml2_0.1.1

wrathematics commented 9 years ago

Thanks for the report. Unfortunately, I'm unable to reproduce with the latest from github on Linux or my 32-bit Windows vm. Have you tried restarting your R session, or possibly reinstalling the package and restarting?

If you're willing to step through the function, you can try running

trace("ngram", browser, exit=browser, signature="character")

Once the object out is defined, entering str(out) should show something like:

List of 4
 $ str_ptr:<externalptr> 
 $ wl_ptr :<externalptr> 
 $ ngl_ptr:<externalptr> 
 $ ngsize : int 5

From the error, it sounds like ngl_ptr specifically isn't getting defined, which I find very strange. At some point a version or two ago, ngl_ptr was ng_ptr, so the only guess I have is that you had an old version installed with some portion of the namespace loaded and you need to restart your R session to get the new stuff. It's a long shot, but it's all I've got right now!

SteveBronder commented 9 years ago

Sorry for the late reply! It also works fine on my ubuntu and windows computers at home. I have not had time to run it again on that particular computer, but your answer makes the most sense. Thanks for your response.