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
sourceimpl Debug for TfIdfMethod
impl Debug for TfIdfMethod
sourceimpl Hash for TfIdfMethod
impl Hash for TfIdfMethod
sourceimpl PartialEq<TfIdfMethod> for TfIdfMethod
impl PartialEq<TfIdfMethod> for TfIdfMethod
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.