[−][src]Struct eddie::slice::Jaro
Jaro similarity.
Usage
use eddie::slice::Jaro; let jaro = Jaro::new(); let sim = jaro.similarity(&[1, 2, 3, 4, 5], &[1, 3, 2, 4, 5]); assert!((sim - 0.93).abs() < 0.01);
Complementary metrics
Relative distance:
let sim = jaro.similarity(s1, s2); let dist = jaro.rel_dist(s1, s2); assert_eq!(dist, 1.0 - sim);
Methods
impl Jaro
[src]
pub fn new() -> Self
[src]
Creates a new instance of Jaro struct with an internal state for the metric methods to reuse.
Example
use eddie::slice::Jaro; let jaro = Jaro::new();
pub fn similarity<T: PartialEq + Copy>(&self, slice1: &[T], slice2: &[T]) -> f64
[src]
Similarity metric. Reflects how close two slices are, ranging from 1.0 (equality) to 0.0 (nothing in common).
Example
let sim = jaro.similarity(&[1, 2, 3, 4, 5], &[1, 3, 2, 4, 5]); assert!((sim - 0.93).abs() < 0.01);
pub fn rel_dist<T: PartialEq + Copy>(&self, slice1: &[T], slice2: &[T]) -> f64
[src]
Relative distance metric. Inversion of similarity. Reflects how far apart two slices are, ranging from 0.0 (equality) to 1.0 (nothing in common).
Example
let dist = jaro.rel_dist(&[1, 2, 3, 4, 5], &[1, 3, 2, 4, 5]); assert!((dist - 0.06).abs() < 0.01);
Auto Trait Implementations
impl !RefUnwindSafe for Jaro
impl Send for Jaro
impl !Sync for Jaro
impl Unpin for Jaro
impl UnwindSafe for Jaro
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,