vectorize.words: Word vectorization

vectorize.wordsR Documentation

Word vectorization

Description

Vectorize words from a corpus of documents.

Usage

vectorize.words(
  corpus = NULL,
  ndim = 50,
  maxwords = NULL,
  mincount = 5,
  minphrasecount = NULL,
  window = 5,
  maxcooc = 10,
  maxiter = 10,
  epsilon = 0.01,
  lang = "en",
  stopwords = lang,
  excludewords = NULL,
  removesinglechars = TRUE,
  ...
)

Arguments

corpus

The corpus of documents (a vector of characters).

ndim

The number of dimensions of the vector space.

maxwords

The maximum number of words.

mincount

Minimum word count to be considered as frequent.

minphrasecount

Minimum collocation of words count to be considered as frequent.

window

Window for term-co-occurrence matrix construction.

maxcooc

Maximum number of co-occurrences to use in the weighting function.

maxiter

The maximum number of iteration to fit the GloVe model.

epsilon

Defines early stopping strategy when fit the GloVe model.

lang

The language of the documents (NULL if no stemming).

stopwords

The language whose stop words are removed ("en", ...), or NULL to keep them. A list of words of your own goes to excludewords.

excludewords

An optional custom vector of additional words to exclude from the vocabulary (e.g. corpus-specific stop words), on top of (or instead of) the language stopwords given through stopwords.

removesinglechars

Whether single-character tokens are removed during cleanup.

...

Other parameters.

Value

The vectorized words.

See Also

query.words, stopwords, vectorizers

Examples


# 'capitals' is small, so the word vectors are coarse and 'ndim' is reduced
# accordingly; phrase detection needs a much larger corpus.
data (capitals)
words = vectorize.words (capitals, mincount = 2, ndim = 10, maxiter = 5)
query.words (words, origin = "paris", sub = "france", add = "germany")
query.words (words, origin = "berlin", sub = "germany", add = "france")


fdm2id documentation built on Aug. 28, 2026, 9:07 a.m.