Wrapper around get_sentence_representation
to return
the fastText
word-vector representation
of words or multiwords, stored in a column of a data frame 'word_df
.
Arguments
- word_df
A data.frame containing a column with words or multiword expressions.
- model
A fastText model, loaded by
fastrtext::load_model()
.- word_field
A character string indicating the name of the column in word_df that contains the words.
- normalize
Logical. Default
TRUE
. Normalize the vectors to their Euclidean norm?
Value
A sparse matrix of class dgCMatrix as
returned by Matrix
.
Has the same number of rows as word_df
and same number of columns
as dimensions of the model
.
Examples
model <- fastrtext::load_model(system.file("extdata",
"tw_demo_model_sml.bin",
package = "dictvectoR"))
word_df <- data.frame(words = c("das ist", "ein", "test"))
word_rep <- get_word_representations(word_df, model)