TFIDFEngine

Trait TFIDFEngine 

Source
pub trait TFIDFEngine<N>: Send + Sync
where N: Num + Copy,
{ // Required methods fn tf_vec( freq: &TermFrequency, term_dim_sample: &IndexSet<Box<str>>, ) -> TFVector<N>; fn tf_denorm(val: N) -> u32; // Provided method fn idf_vec(corpus: &Corpus, term_dim_sample: &Vec<Box<str>>) -> Vec<f32> { ... } }
Expand description

TF-IDF Calculation Engine Trait

Defines the behavior of a TF-IDF calculation engine.

Custom engines can be implemented and plugged into [TFIDFVectorizer].

A default implementation, DefaultTFIDFEngine, is provided.

§Supported Numeric Types

  • f16
  • f32
  • u16
  • u32

Required Methods§

Source

fn tf_vec( freq: &TermFrequency, term_dim_sample: &IndexSet<Box<str>>, ) -> TFVector<N>

Method to generate the TF vector

§Arguments
  • freq - term frequency
  • term_dim_sample - term dimension sample
§Returns
  • (ZeroSpVec<N>, f64) - TF vector and value for denormalization
Source

fn tf_denorm(val: N) -> u32

Provided Methods§

Source

fn idf_vec(corpus: &Corpus, term_dim_sample: &Vec<Box<str>>) -> Vec<f32>

Method to generate the IDF vector

§Arguments
  • corpus - The corpus
  • term_dim_sample - term dimension sample
§Returns
  • Vec<N> - The IDF vector
  • denormalize_num - Value for denormalization

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§