Sentence_Vector {LilRhino}R Documentation

Function for extracting the sentence vector from an embeddings matrix.

Description

Function for extracting the sentence vector from an embeddings matrix in a fast and convenient manner.

Usage

Sentence_Vector(Sentence, emb_matrix, dimension, stopwords)

Arguments

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.

Details

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.

Value

The sentence vector from an embeddings matrix.

Author(s)

Travis Barton

Examples

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



[Package LilRhino version 1.2.2 Index]