2

I am trying to replicate the example given in the following link

https://cran.r-project.org/web/packages/text2vec/vignettes/glove.html.

I have unzipped the file manually.

I am getting the following error at this stage

library(text2vec)
wiki = readLines("~text8", n = 1, warn = FALSE)
tokens <- space_tokenizer(wiki)
it = itoken(tokens, progressbar = FALSE)
vocab <- create_vocabulary(it)
vocab <- prune_vocabulary(vocab, term_count_min = 5L)
vectorizer <- vocab_vectorizer(vocab)
# use window of 5 for context words
tcm <- create_tcm(it, vectorizer, skip_grams_window = 5L)
glove = GlobalVectors$new(word_vectors_size = 50, vocabulary = vocab, x_max = 10)
glove$fit(tcm, n_iter = 20)

Error: attempt to apply non-function

Any help would be great.

NinjaR
  • 621
  • 6
  • 22
  • 1
    It looks like `glove$fit` doesn't exist anymore - there isn't a `fit` method available, only a `fit_transform` and a `transform`. Not sure why that is, but you can run `glove$fit_transform(tcm, n_iter = 20)` and it shows the output as expected. Might be worth flagging it with the package owners. – meenaparam Jul 27 '18 at 20:29
  • 4
    The more recent vignette / guide can be found at [http://text2vec.org/glove.html](http://text2vec.org/glove.html). For GloVe there is only a `fit_transform` method, see `?GloVe` in the Methods section, at least in the current CRAN version, i.e., 0.5.1. – Manuel Bickel Jul 27 '18 at 21:28

0 Answers0