Enum imdb_index::Similarity
source · pub enum Similarity {
None,
Levenshtein,
Jaro,
JaroWinkler,
}
Expand description
A ranking function to use when searching IMDb records.
A similarity ranking function computes a score between 0.0
and 1.0
(not
including 0
but including 1.0
) for a query and a candidate result. The
score is determined by the corresponding names for a query and a candidate,
and a higher score indicates more similarity.
This ranking function can be used to increase the precision of a set
of results. In particular, when a similarity function is provided to
a Query
, then any results returned by querying
the IMDb name index will be rescored according to this function. If no
similarity function is provided, then the results will be ranked according
to scores produced by the name index.
Variants§
None
Do not use a similarity function.
Levenshtein
Computes the Levenshtein edit distance between two names and converts it to a similarity.
Jaro
Computes the Jaro edit distance between two names and converts it to a similarity.
JaroWinkler
Computes the Jaro-Winkler edit distance between two names and converts it to a similarity.
Implementations§
source§impl Similarity
impl Similarity
sourcepub fn possible_names() -> &'static [&'static str]
pub fn possible_names() -> &'static [&'static str]
Returns a list of s trings representing the possible similarity function names.
sourcepub fn similarity(&self, q1: &str, q2: &str) -> f64
pub fn similarity(&self, q1: &str, q2: &str) -> f64
Computes the similarity between the given strings according to the
underlying similarity function. If no similarity function is present,
then this always returns 1.0
.
The returned value is always in the range (0, 1]
.
Trait Implementations§
source§impl Clone for Similarity
impl Clone for Similarity
source§fn clone(&self) -> Similarity
fn clone(&self) -> Similarity
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for Similarity
impl Debug for Similarity
source§impl Default for Similarity
impl Default for Similarity
source§fn default() -> Similarity
fn default() -> Similarity
source§impl Display for Similarity
impl Display for Similarity
source§impl FromStr for Similarity
impl FromStr for Similarity
source§impl Hash for Similarity
impl Hash for Similarity
source§impl PartialEq for Similarity
impl PartialEq for Similarity
source§fn eq(&self, other: &Similarity) -> bool
fn eq(&self, other: &Similarity) -> bool
self
and other
values to be equal, and is used
by ==
.