View source: R/Personal_Functions.R
Sentence_Vector | R Documentation |
Function for extracting the sentence vector from an embeddings matrix in a fast and convenient manner.
Sentence_Vector(Sentence, emb_matrix, dimension, stopwords)
Sentence |
The sentence to find the vector of. |
emb_matrix |
The embeddings matrix to search. |
dimension |
The dimension of the vector to return. |
stopwords |
Words that should not be included in the averaging proccess. |
The function splits the sentence into words, eliminates all stopwords, finds the vectors of each word, then averages the word vectors into a sentence vector.
The sentence vector from an embeddings matrix.
Travis Barton
emb = data.frame(matrix(c(1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1, 5, 3, 2, 4), nrow = 3), row.names = c('sentence', 'in', 'question')) Sentence_Vector(c('this is the sentence in question'), emb, 5, c('this', 'is', 'the'))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.