BOW_train: Train a Bag-of-Words Model

View source: R/BOW.R

BOW_trainR Documentation

Train a Bag-of-Words Model

Description

Train a Bag-of-Words Model

Usage

BOW_train(doc, weighting_scheme = "bow", ngram_size = 1)

Arguments

doc

A character vector of documents to be processed.

weighting_scheme

A string specifying the weighting to apply. Defaults to "bag_of_words".

  • "bag_of_words" (Alias: "bow") - Standard count of words.

  • "term_frequency" (Alias: "tf") - Normalized counts (frequency relative to document length).

  • "tfidf" (Alias: "tf-idf") - Term Frequency-Inverse Document Frequency.

  • "binary" - Presence/Absence (1/0).

ngram_size

An integer specifying the maximum n-gram size. For example, 'ngram_size = 1' will create unigrams only; 'ngram_size = 2' will create unigrams and bigrams. Defaults to 1.

Value

An object of class "qs_bow_fit" containing:

  • dfm_template: a quanteda dfm template

  • weighting_scheme: the weighting used

  • ngram_size: the n-gram size used

#'

Examples

txt <- c("text one", "text two text")
fit <- BOW_train(txt, weighting_scheme = "bow")
fit$dfm_template


quickSentiment documentation built on Aug. 29, 2026, 1:07 a.m.