[−][src]Struct eddie::str::JaroWinkler
Jaro-Winkler similarity.
Like Jaro similarity but gives a higher score to the strings that start with the same sequence of characters.
Usage
use eddie::JaroWinkler; let jarwin = JaroWinkler::new(); let sim = jarwin.similarity("martha", "marhta"); assert!((sim - 0.96).abs() < 0.01);
Complementary metrics
Relative distance:
let sim = jarwin.similarity(s1, s2); let dist = jarwin.rel_dist(s1, s2); assert_eq!(dist, 1.0 - sim);
Methods
impl JaroWinkler
[src]
pub fn new() -> JaroWinkler
[src]
Creates a new instance of JaroWinkler struct with an internal state for the metric methods to reuse.
Example
use eddie::JaroWinkler; let jarwin = JaroWinkler::new();
pub fn set_scaling(&mut self, scaling: f64) -> &mut Self
[src]
Sets scaling factor for common prefix score boost.
Default value is 0.1.
Panics if it's not in range [0.0, 0.25]
.
Example
let mut jarwin = JaroWinkler::new(); let sim1 = jarwin.similarity("martha", "marhta"); jarwin.set_scaling(0.25); let sim2 = jarwin.similarity("martha", "marhta"); assert!((sim1 - 0.96).abs() < 0.01); assert!((sim2 - 0.98).abs() < 0.01);
pub fn similarity(&self, str1: &str, str2: &str) -> f64
[src]
Similarity metric. Reflects how close two strings are, ranging from 1.0 (equality) to 0.0 (nothing in common).
Example
let sim = jarwin.similarity("martha", "marhta"); assert!((sim - 0.96).abs() < 0.01);
pub fn rel_dist(&self, str1: &str, str2: &str) -> f64
[src]
Relative distance metric. Inversion of similarity. Reflects how far apart two strings are, ranging from 0.0 (equality) to 1.0 (nothing in common).
Example
let dist = jarwin.rel_dist("martha", "marhta"); assert!((dist - 0.04).abs() < 0.01);
Auto Trait Implementations
impl !RefUnwindSafe for JaroWinkler
impl Send for JaroWinkler
impl !Sync for JaroWinkler
impl Unpin for JaroWinkler
impl UnwindSafe for JaroWinkler
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>,