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_releasesfollows. The comparison istext::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_releasesandmoved_towere 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.