///|
fn encode_normalized_keys(
normalized : String,
algorithm : Algorithm,
) -> EncodedKeys {
match algorithm {
Soundex => EncodedKeys::single(soundex(normalized))
RefinedSoundex => EncodedKeys::single(refined_soundex(normalized))
Nysiis => EncodedKeys::single(nysiis(normalized))
Metaphone => EncodedKeys::single(metaphone(normalized))
DoubleMetaphone => double_metaphone(normalized)
Caverphone1 => EncodedKeys::single(caverphone1(normalized))
Caverphone2 => EncodedKeys::single(caverphone2(normalized))
MatchRating => EncodedKeys::single(match_rating_codex(normalized))
}
}
///|
/// Normalizes input with an explicit policy and returns all keys produced by
/// the selected encoder.
pub fn encode_keys(
input : String,
algorithm : Algorithm,
normalization : NormalizationConfig,
) -> Result[EncodedKeys, NormalizationError] {
match normalize_name(input, normalization) {
Err(error) => Err(error)
Ok(result) => Ok(encode_normalized_keys(result.normalized, algorithm))
}
}