Sentence_Vector: Function for extracting the sentence vector from an...

Description Usage Arguments Details Value Author(s) Examples

View source: R/Personal_Functions.R

Description

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

Usage

1
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

1
2
3
4
5
  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'))

LilRhino documentation built on Oct. 31, 2019, 4:59 p.m.