Skip to main content

Vectorizer

Trait Vectorizer 

Source
pub trait Vectorizer: Clone {
    // Required methods
    fn fit(&mut self, texts: &[&str]) -> Result<()>;
    fn transform(&self, text: &str) -> Result<Array1<f64>>;
    fn transform_batch(&self, texts: &[&str]) -> Result<Array2<f64>>;

    // Provided method
    fn fit_transform(&mut self, texts: &[&str]) -> Result<Array2<f64>> { ... }
}
Expand description

Trait for text vectorizers

Required Methods§

Source

fn fit(&mut self, texts: &[&str]) -> Result<()>

Fit the vectorizer on a corpus of texts

Source

fn transform(&self, text: &str) -> Result<Array1<f64>>

Transform a text into a vector

Source

fn transform_batch(&self, texts: &[&str]) -> Result<Array2<f64>>

Transform a batch of texts into a matrix where each row is a document vector

Provided Methods§

Source

fn fit_transform(&mut self, texts: &[&str]) -> Result<Array2<f64>>

Fit on a corpus and then transform a batch of texts

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§