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§
source§impl TfIdfMethod
impl TfIdfMethod
pub fn compute_idf(&self, n: usize, df: usize) -> f64
Trait Implementations§
source§impl Clone for TfIdfMethod
impl Clone for TfIdfMethod
source§fn clone(&self) -> TfIdfMethod
fn clone(&self) -> TfIdfMethod
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for TfIdfMethod
impl Debug for TfIdfMethod
source§impl Hash for TfIdfMethod
impl Hash for TfIdfMethod
source§impl PartialEq for TfIdfMethod
impl PartialEq for TfIdfMethod
source§fn eq(&self, other: &TfIdfMethod) -> bool
fn eq(&self, other: &TfIdfMethod) -> bool
self
and other
values to be equal, and is used
by ==
.impl Eq for TfIdfMethod
impl StructuralEq for TfIdfMethod
impl StructuralPartialEq for TfIdfMethod
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§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.