Creates sentence embeddings by averaging word vectors with IDF weighting
dimEmbedding dimension
vocab_sizeVocabulary size
new()Create a new SentenceEmbedder
SentenceEmbedder$new(word_vectors, use_idf = TRUE, smooth_idf = 1)word_vectorsWordVectors object from load_word_vectors()
use_idfUse IDF weighting (recommended)
smooth_idfSmoothing for IDF
fit()Fit IDF weights on a corpus
SentenceEmbedder$fit(texts)textsCharacter vector of texts
textsCharacter vector of texts
Matrix of embeddings (rows are sentences)
get_word_vector()Get word vector for a single word
SentenceEmbedder$get_word_vector(word)wordWord to look up
Numeric vector or NULL if not found
has_word()Check if word is in vocabulary
SentenceEmbedder$has_word(word)wordWord to check
Logical
most_similar()Find most similar words
SentenceEmbedder$most_similar(word, n = 10)wordQuery word
nNumber of results
Data frame with word and similarity
clone()The objects of this class are cloneable with this method.
SentenceEmbedder$clone(deep = FALSE)deepWhether to make a deep clone.