Questions tagged [text2vec]
text2vec - R package which provides a fast and memory efficient framework for text mining applications within R. Vectorization, word embeddings, topic modelling and more.
110
questions
0
votes
0
answers
50
views
Including a covariate in a word embedding model in R using text2vec and quanteda packages
I am trying to build a word embedding model in r with the following code:
library(quanteda)
library(text2vec)
fcm_ <- fcm(tokens, context = "window", count = "weighted", ...
1
vote
0
answers
34
views
How to calculate the coherence score for a LDA model?
I want to use coherence and perplexity to decide the best K(number of topics) in topic modeling. The sample of my dataset is:
doc_id <- c(1:20)
date <- c(1901:1920)
text <- c("contribut ...
0
votes
1
answer
172
views
How can I hide messages in R markdown when "message=FALSE" doesn't work
I am using R Markdown and text2vec and would like to suppress the messages that come from running the function glove$fit_transform(). I've tried message=FALSE and warning=FALSE, as well as a number ...
0
votes
1
answer
516
views
How can I solve my problems with the installation of the text2vec package?
I'm trying to install the R package text2vec, I get the following error.
It says it cannot open a certain shared object file.
> install.packages("text2vec")
Error in dyn.load(file, ...
1
vote
1
answer
76
views
text2vec word embeddings : compound some tokens but not all
I am using {text2vec} word embeddings to build a dictionary of similar terms pertaining to a certain semantic category.
Is it OK to compound some tokens in the corpus, but not all? For example, I want ...
0
votes
0
answers
497
views
Viewing saved LDAvis plot from directory in browser
I created an LDAvis figure using the text2veec package in R. Tried but failed to save it to my local directory as the fully interactive webpage that it is.
I get either a blank page in my browser or a ...
1
vote
1
answer
228
views
Export R text2vec Vectors for use in Gensim in Python
I have created GloVE vectors in R previously using text2vec library.
Is there any easy way to export these for use in Python where I have scripts to compare/contract with Gensim created word vectors? ...
0
votes
0
answers
354
views
Error in glove_event$fit_transform in text2vec package
While experimenting with word embedding using text2vec package in R, the following error is thrown
embd_dim <- 5
glove_event <- GlobalVectors$new(rank = embd_dim, x_max = 10,learning_rate = 0....
0
votes
1
answer
101
views
text2vec's vocab_vectorizer ouput is the function itself
I am trying to run through text2vec's example on this page. However, whenever I try to see what the vocab_vectorizer function returned, it's just an output of the function itself. In all my years of ...
0
votes
1
answer
173
views
R : error inherits(x, "matrix") || inherits(x, "Matrix") is not TRUE when trying to calculate cosine similarity with tf-idf
I have a corpus filled with 5 different books (all .txt files). I want to calculate the cosine similarity between these books, so I can tell how similar they are with one another. Following is my code:...
2
votes
0
answers
418
views
Support for large sparse matrices R
Is there any support for large sparse matrices in R? I'm currently dealing with a 1.9M sparse square matrix with about 0.001 density.
I wanted to stress test the creating of this matrix in R on my ...
-1
votes
1
answer
82
views
text2vec document similarity code returns two values
I am learning to assess text similarity in between documents. Going through the text2vec tutorial (http://text2vec.org/similarity.html) on the topic, I noticed that the code returns two values for ...
0
votes
1
answer
368
views
R text2vec; rsparse::GloVe$new() GlobalVectors$new() Env Set/Not Set
Problem: R GloVe environment using library(text2vec). Set environment with code execution of rsparse::GloVe$new(), BUT, not set with code execution of GlobalVectors$new().
Then ran wv_main = glove$...
1
vote
1
answer
511
views
gloVe fit function issue with text2vect package in r
I am new to gloVe word embeddings for nlp/deep learning models in R but I find them very useful. I am experiencing problems implementing the model in r. When I use correct constructor:
glove <- ...
-1
votes
1
answer
414
views
Combine two words in a corpus with R
So here is my code
ny <- read.csv2("nyt.csv", sep = "\t", header = T)
ny_texte <- as.vector(ny)
iterator <- itoken(ny_texte,
preprocessor=tolower,
...
0
votes
1
answer
90
views
Return several objects from a shiny server function in R for plotting an LDAvis plot first
The code below is the one I am using for plotting an LDA plot using text2vec inside topic_model function in a shiny app. input$date is a checkboxGroupInput selection, input$data works perfectly fine ...
1
vote
1
answer
866
views
Elbow/knee in a curve in R
I've got this data processing:
library(text2vec)
##Using perplexity for hold out set
t1 <- Sys.time()
perplex <- c()
for (i in 3:25){
set.seed(17)
lda_model2 <- LDA$new(n_topics = i)
...
0
votes
1
answer
99
views
I can't create tf-idf matrix for my test data using text2vec
I'm following this tutorial and doing it as I did the training set, but it keeps saying the same thing. Someone know what's wrong with this?
> #Construct sample document-term matrix con el ...
0
votes
1
answer
59
views
Why are distances in text2vec's RWMD module between 1 and -1?
From what I understand, the dist2 RWMD feature of the great text2vec package calculates distances between matrixes as cosine distances. Wouldn't that mean 1 - (cosine similarity)? If cosine similarity ...
0
votes
1
answer
178
views
Error while finding topics quantity on Latent Dirichlet Allocation model using ldatuning library
This is the outcome error and I can tell this is because there is at least one document without some term, but I don't get why and how I can solve it.
prep_fun = function(x) {
x %>%
...
0
votes
1
answer
102
views
Perplexity issues using text2vec
I am ussing text2vec on 230k docs, as I always mention. I am trying to find the best topic number for my document term matrix by using perplexity. When I use it one by one it works perfectly fine, but ...
0
votes
0
answers
199
views
Where can I find the coherence funtion in r?
Excuse me for being basic, but I want to use the 'coherence' function I found on this link to evaluate my latent dirichlet allocation topics and it isn't working with text2vec and I can't tell which ...
1
vote
0
answers
388
views
Pre-initialize weights in glove use Initial parameter in glove text2vec fit_transform
I would like to pre-initialise glove, word vectors and biases using the initial parameter of the fit_transform. The documentation of the function states to pass as a named list "w_i, w_j, b_i, b_j" ...
1
vote
0
answers
316
views
Calculate aggrgeate cosine and Jaccard distance between two sets of documents
I collected a list of abstracts from online news websites and manually labelled them, by topic, using their original labels (e.g., politics, entertainment, sports, finance, etc.). Now I want to ...
1
vote
1
answer
41
views
Join doc_topic_distr with DTM raw data using doc_id
I want to try some kind of prediction stuff similar to this one:
https://www.quora.com/How-do-I-use-LDA-Latent-Dirichlet-Allocation-for-document-classification-preferably-with-solutions-that-can-be-...
1
vote
1
answer
184
views
Why do fit_transform and transform produce different results?
I was playing around with LDA in the text2vec package and was confused why the fit_transfrom and transform were different when using the same data.
The documentation states that transform applys the ...
0
votes
1
answer
55
views
Why does text2vec show more files than actually exist?
I am testing text2vec. There are only 2 files under a dir (1.txt, 2.txt, of very small size, about 20 k each). I wanted to test their similarity. I do not know why it says 54 documents.
> library(...
1
vote
1
answer
1k
views
Read GloVe pre-trained embeddings into R, as a matrix
Working in R. I know the pre-trained GloVe embeddings (e.g., "glove.6B.50d.txt") can be found here: https://nlp.stanford.edu/projects/glove/. However, I've had zero luck reading this text file into R ...
0
votes
1
answer
90
views
convert R matrix to text2vec dtm
I have a R matrix mat and I want to perform LDA on it.
When I run lda_model$fit_transform(mat, n_iter = 20), I get an error:
Error in super$check_convert_input(x) :
don't know how to deal with ...
2
votes
0
answers
156
views
R package text2vec--tokenize to sequences
I see lots of functionality in the text2vec package to tokenize strings and make DTMs, but is there a way to create sequences? The Rstudio keras library has this, but it is incredibly slow. The idea ...
1
vote
2
answers
276
views
Why is LSA in text2vec producing different results every time?
I was using latent semantic analysis in the text2vec package to generate word vectors and using transform to fit new data when I noticed something odd, the spaces not being lined up when trained on ...
1
vote
0
answers
573
views
Relaxed Word Mover's Distance in R
I am using Relaxed Word Mover's Distance in the package text2vec to compute the distance between documents, so as to identify the most similar document for each target document. Word vectors are ...
1
vote
1
answer
1k
views
Using GLOVEs pretrained glove.6B.50.txt as a basis for word embeddings R
I'm trying to convert textual data into vectors using GLOVE in r. My plan was to average the word vectors of a sentence, but I can't seem to get to the word vectorization stage. I've downloaded the ...
-1
votes
1
answer
571
views
Text Similarity - Cosine - Control
I would like to ask you, if anybody could check my code, because it was behaving weird - not working, giving me errors to suddenly working without changing anything - the code will be at the bottom.
...
0
votes
1
answer
509
views
hash vectorizer in R text2vec package with stopwords removal option
I am using R text2vec package for creating document-term-matrix. Here is my code:
library(lime)
library(text2vec)
# load data
data(train_sentences, package = "lime")
#
tokens <- ...
0
votes
1
answer
487
views
Using text2vec in R - Error: no package called ‘futile.options’
I successfully installed text2vec in R, but when I try to load it with library(text2vec), I'm getting an error:
Error: package or namespace load failed for ‘text2vec’ in loadNamespace(i, c(lib.loc, ....
1
vote
1
answer
275
views
How to represent each word occurrence as a separate tcm vector in R?
I am looking for an efficient way to create a term co-occurrence matrix for (each) target word in a corpus, such that each occurrence of the word would constitute its own vector (row) in a tcm, where ...
0
votes
1
answer
226
views
using text2vec for multilabel classification
I want to know if text2vec package can be used for multilabel classification like python's BinaryRelevance in skmultilearn.problem_transform
I'm currently referring to the pipeline documented at:
http:...
1
vote
1
answer
889
views
LDA topic model using R text2vec package and LDAvis in shinyApp
Here is the code for LDA topic modelling with R text2vec package:
library(text2vec)
tokens = docs$text %>% # docs$text: a colection of text documents
word_tokenizer
it = itoken(tokens, ids =...
0
votes
1
answer
481
views
Glove Word Mover Similarity
I want to calculate text similarity using relaxed word movers distance. I have two different datasets (corpus). See below.
A <- data.frame(name = c(
"X-ray right leg arteries",
"consultation ...
0
votes
1
answer
447
views
Word Mover Distance Similarity in R
I want to calculate text similarity using relaxed word movers distance. I have two different datasets (corpus). See below.
A <- data.frame(name = c(
"X-ray right leg arteries",
"consultation ...
0
votes
1
answer
842
views
Glove word embedding model parameters using tex2vec in R, and display training output (epochs) after every n iterations
I am using text2vec package in R for training word embedding (Glove Model) as:
library(text2vec)
library(tm)
prep_fun = tolower
tok_fun = word_tokenizer
tokens = docs %>% # docs: a collection of ...
2
votes
0
answers
139
views
Beginner advice about adding start/end sentence markers: using Quanteda functionalities versus doing it manually (custom code)
I need to add begin and end sentence markers to some texts that I analyze using Quanteda.
I would like to add these markers using Quanteda but I do not see an explicit way to do that "out of the box".
...
0
votes
1
answer
797
views
Create Co-occurrence matrix with bigrams
I am looking to create a co-occurrence matrix with bigrams in stead of unigrams from a single string. I am referring the following links
http://text2vec.org/glove.html
https://tm4ss.github.io/docs/...
2
votes
0
answers
704
views
Error: attempt to apply non-function in text2vec
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 ...
1
vote
2
answers
810
views
R function with reference to argument without evaluating it
islands1<-islands #a named num (vector)
data.frame(island_col=names(islands1), number_col=islands1,row.names=NULL)
This creates a dataframe consisting of two columns, the first contains the names ...
0
votes
2
answers
182
views
looping to tokenize using text2vec
Edited to shorten and provide sample data.
I have text data consisting of 8 questions asked of a number of participants twice. I want to use text2vec to compare the similarity of their responses to ...
7
votes
2
answers
7k
views
Is there any reason to (not) L2-normalize vectors before using cosine similarity?
I was reading the paper "Improving Distributional Similarity
with Lessons Learned from Word Embeddings" by Levy et al., and while discussing their hyperparameters, they say:
Vector Normalization (...
0
votes
1
answer
460
views
Get LDAvis json from text2vec
Given a document term matrix dtm, text2vec provides a nice integration with the LDAvis package. However, I want to embed this visualisation into a markdown document. The LDAvis package has methods ...
1
vote
1
answer
160
views
how to train a lasso with both text and numeric variables?
Consider this modified classic example:
library(dplyr)
library(tibble)
dtrain <- data_frame(text = c("Chinese Beijing Chinese",
"Chinese Chinese Shanghai",
...