pub enum TfIdfMethod {
Smooth,
NonSmooth,
Textbook,
}
Expand description
Methods for computing the inverse document frequency of a vocabulary entry
Variants
Smooth
Computes the idf as log(1+n/1+document_frequency) + 1
. The “plus ones” inside the log
add an artificial document containing every vocabulary entry, preventing divisions by zero.
The “plus one” after the log allows vocabulary entries that appear in every document to still be considered with
a weight of one instead of being completely discarded.
NonSmooth
Computes the idf as log(n/document_frequency) +1
. The “plus one” after the log allows vocabulary entries that appear in every document to still be considered with
a weight of one instead of being completely discarded. If a vocabulary entry has zero document frequency this will produce a division by zero.
Textbook
Textbook definition of idf, computed as log(n/ 1 + document_frequency)
which prevents divisions by zero and discards entries that appear in every document.
Implementations
sourceimpl TfIdfMethod
impl TfIdfMethod
pub fn compute_idf(&self, n: usize, df: usize) -> f64
Trait Implementations
sourceimpl Clone for TfIdfMethod
impl Clone for TfIdfMethod
sourcefn clone(&self) -> TfIdfMethod
fn clone(&self) -> TfIdfMethod
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
Auto Trait Implementations
impl RefUnwindSafe for TfIdfMethod
impl Send for TfIdfMethod
impl Sync for TfIdfMethod
impl Unpin for TfIdfMethod
impl UnwindSafe for TfIdfMethod
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more