Function best_match

Source
pub fn best_match<F: Clone>(
    candidates: &[Candidate<F>],
    wanted: &str,
) -> Result<(Candidate<F>, Confidence), NoMatch>
Expand description

Picks the answer that describes the thing asked about, or says why none does.

Two rules, both taken from behaviour this codebase already has:

  • An exact name match wins, and only widens when nothing matches exactly — the rule Catalog::find_releases follows. The comparison is text::normalize, the same function that decides two spellings are one name everywhere else.
  • Several equally good answers are refused, not arbitrated. Returning the first of them is an arbitrary answer given without saying so, which is the fault find_releases and moved_to were both fixed for.

A name is not an identity: equally ranked candidates with different MBIDs remain ambiguous even when their names normalize alike. Repeated spellings of the same MBID are one candidate.

This search helper always returns Confidence::Matched, however sure the answer looks. Identifier lookups are handled separately.