as.textmodel_lss: Create a Latent Semantic Scaling model from various objects

View source: R/as.textmodel.R

as.textmodel_lssR Documentation

Create a Latent Semantic Scaling model from various objects

Description

Create a new textmodel_lss object from an existing or foreign objects.

Usage

as.textmodel_lss(x, ...)

## S3 method for class 'matrix'
as.textmodel_lss(
  x,
  seeds,
  terms = NULL,
  slice = NULL,
  simil_method = "cosine",
  auto_weight = FALSE,
  verbose = FALSE,
  ...
)

## S3 method for class 'numeric'
as.textmodel_lss(x, ...)

## S3 method for class 'textmodel_lss'
as.textmodel_lss(x, ...)

## S3 method for class 'textmodel_wordvector'
as.textmodel_lss(x, seeds, terms = NULL, verbose = FALSE, spatial = TRUE, ...)

Arguments

x

an object from which a new textmodel_lss object is created. See details.

...

arguments used to create a new object. seeds must be given when x is a dense matrix or a fitted textmodel_lss.

seeds

a character vector or named numeric vector that contains seed words. If seed words contain "*", they are interpreted as glob patterns. See quanteda::valuetype.

terms

a character vector or named numeric vector that specify words for which polarity scores will be computed; if a numeric vector, words' polarity scores will be weighted accordingly; if NULL, all the features in x except those less frequent than min_count will be used.

slice

a number or indices of the components of word vectors used to compute similarity; slice < k to further truncate word vectors; useful for diagnosys and simulation.

simil_method

specifies method to compute similarity between features. The value is passed to quanteda.textstats::textstat_simil(), "cosine" is used otherwise.

auto_weight

automatically determine weights to approximate the polarity of terms to seed words. Deprecated.

verbose

show messages if TRUE.

spatial

if TRUE, return a spatial model. Otherwise, a probabilistic model.

Details

If x is a textmodel_lss, original word vectors are reused to compute polarity scores with new seed words. It is also possible to subset word vectors via slice if it was trained originally using SVD.

If x is a dense matrix, it is treated as a column-oriented word vectors with which polarity of words are computed. If x is a named numeric vector, the values are treated as polarity scores of the words in the names.

Value

a dummy textmodel_lss object


LSX documentation built on Sept. 13, 2025, 1:10 a.m.

Related to as.textmodel_lss in LSX...