pub struct Result<R> { /* private fields */ }Expand description
Result of a distance/similarity algorithm.
Implementations§
Source§impl Result<usize>
impl Result<usize>
Sourcepub fn val(&self) -> usize
pub fn val(&self) -> usize
Raw value of the metric.
It is equivalent to dist for distance metrics
and to sim for similarity metrics.
use textdistance::{Algorithm, Hamming};
let h = Hamming::default();
let res = h.for_str("abc", "acbd");
assert!(res.val() == 3);Sourcepub fn dist(&self) -> usize
pub fn dist(&self) -> usize
Absolute distance.
A non-negative number showing how different the two sequences are. Two exactly the same sequences have the distance 0.
The highest possible number varies based on the length of the input strings. Most often, each increment of this value indicates one symbol that differs in the input sequences.
use textdistance::{Algorithm, Hamming};
let h = Hamming::default();
let res = h.for_str("abc", "acbd");
assert!(res.dist() == 3);Sourcepub fn sim(&self) -> usize
pub fn sim(&self) -> usize
Absolute similarity.
A non-negative number showing how similar the two sequences are. Two absolutely different sequences have the similarity 0.
The highest possible number varies based on the length of the input strings. Most often, each increment of this value indicates one symbol that is the same in both sequences.
use textdistance::{Algorithm, Hamming};
let h = Hamming::default();
let res = h.for_str("abc", "acbd");
assert!(res.sim() == 1); // "a"Sourcepub fn nval(&self) -> f64
pub fn nval(&self) -> f64
Normalized raw value of the metric.
It is equivalent to ndist for distance metrics
and to nsim for similarity metrics.
use textdistance::{Algorithm, Hamming};
let h = Hamming::default();
let res = h.for_str("abc", "acbd");
assert!(res.nval() == 3.0 / 4.0);Sourcepub fn ndist(&self) -> f64
pub fn ndist(&self) -> f64
Normalized distance.
A number from 0.0 to 1.0 showing how different the two sequences are. 0.0 indicates that the sequences are the same, and 1.0 indicates that the sequences are very different.
use textdistance::{Algorithm, Hamming};
let h = Hamming::default();
let res = h.for_str("abc", "acbd");
assert!(res.ndist() == 3.0 / 4.0);Sourcepub fn nsim(&self) -> f64
pub fn nsim(&self) -> f64
Normalized similarity.
A number from 0.0 to 1.0 showing how similar the two sequences are. 0.0 indicates that the sequences are very different, and 1.0 indicates that the sequences are the same.
use textdistance::{Algorithm, Hamming};
let h = Hamming::default();
let res = h.for_str("abc", "acbd");
assert!(res.nsim() == 1.0 / 4.0);Source§impl Result<f64>
impl Result<f64>
Sourcepub fn nval(&self) -> f64
pub fn nval(&self) -> f64
Normalized raw value of the metric.
It is equivalent to ndist for distance metrics
and to nsim for similarity metrics.
use textdistance::{Algorithm, Jaro};
let h = Jaro::default();
let res = h.for_str("test", "tset");
assert_eq!(res.nval(), 0.9166666666666666);Sourcepub fn ndist(&self) -> f64
pub fn ndist(&self) -> f64
Normalized distance.
A number from 0.0 to 1.0 showing how different the two sequences are. 0.0 indicates that the sequences are the same, and 1.0 indicates that the sequences are very different.
use textdistance::{Algorithm, Jaro};
let h = Jaro::default();
let res = h.for_str("test", "tset");
assert_eq!(res.ndist(), 0.08333333333333337);Sourcepub fn nsim(&self) -> f64
pub fn nsim(&self) -> f64
Normalized similarity.
A number from 0.0 to 1.0 showing how similar the two sequences are. 0.0 indicates that the sequences are very different, and 1.0 indicates that the sequences are the same.
use textdistance::{Algorithm, Jaro};
let h = Jaro::default();
let res = h.for_str("test", "tset");
assert_eq!(res.nsim(), 0.9166666666666666);