Description Usage Arguments Details Examples
Shiny application to display closest embeddings to a query User provides a pivot word and the n most similar word are displayed.
1 | shiny_text(annoy_model, word_embeddings_mat, normalize_text)
|
annoy_model |
RcppAnnoy model generated with get_annoy_model |
word_embeddings_mat |
matrix containing embeddings of each word (used to generate the embedding of the query) |
normalize_text |
function to clean the query before being transformed in embedding. Take a character as parameter and return a character. |
Word embeddings are retrieved from the provided matrix and averaged to get the embedding of the query.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | if(interactive()){
# This example should be run with a higher quality model
# than the one embedded in fastrtext
library(projector)
library(fastrtext)
model_test_path <- system.file("extdata",
"model_unsupervised_test.bin",
package = "fastrtext")
model <- load_model(model_test_path)
word_embeddings_mat <- get_word_vectors(model, words = head(get_dictionary(model), 2e5))
annoy_model <- get_annoy_model(word_embeddings_mat, 5)
shiny_text(annoy_model = annoy_model,
word_embeddings_mat = word_embeddings_mat,
normalize_text = tolower)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.