[][src]Struct eddie::JaroWinkler

pub struct JaroWinkler { /* fields omitted */ }

Jaro-Winkler similarity.

Like Jaro similarity but gives a higher score to the strings that start with the same sequence of characters.

See the detailed description.

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

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = !

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.