shiny_text: Interactive approximative search of embeddings (text)

Description Usage Arguments Details Examples

Description

Shiny application to display closest embeddings to a query User provides a pivot word and the n most similar word are displayed.

Usage

1
shiny_text(annoy_model, word_embeddings_mat, normalize_text)

Arguments

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.

Details

Word embeddings are retrieved from the provided matrix and averaged to get the embedding of the query.

Examples

 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)
}

pommedeterresautee/projector documentation built on May 5, 2019, 1:38 p.m.