idf: Inverse document-frequencies Calculator

View source: R/tf_normalizator.R

idfR Documentation

Inverse document-frequencies Calculator

Description

The aims of this function is to compute the Inverse document-frequencies possibly using different functions. The standard one is the log2

Usage

idf(dtm, fun = log2, adjust = TRUE, force = FALSE)

Arguments

dtm

A DocumentTermMatrix filled with the simple term-frequencies weights

fun

The weighting function for the ratio of document-frequencies

adjust

If TRUE (default) adds 1 to the denominator (i.e., the sum of the frequencies of a term into the corpora) to avoid the risk it happen to be zero.

force

(lgl) if TRUE (default is FALSE) the function works also for simple_triplet_matrix which are not DocumentTermMatrix

Value

A numerical vector representing the inverse document-frequencies

Examples

data(liu_dtm)
idf(liu_dtm)
idf(liu_dtm, adjust = FALSE)
idf(liu_dtm, fun = log)

UBESP-DCTV/costumer documentation built on Feb. 1, 2023, 4:52 a.m.