///|
fn example_config() -> @phonetic.MatchConfig {
{
normalization: @phonetic.name_normalization_config(),
encoders: [],
metric: @phonetic.Levenshtein,
string_weight: 1.0,
threshold: 0.8,
token_policy: @phonetic.WholeInput,
unmatched_token_penalty: 0.5,
}
}
///|
fn main {
let records : Array[@phonetic.DedupInput] = [
{ id: "r1", name: "Robert" },
{ id: "r2", name: "Rupert" },
{ id: "r3", name: "Rubert" },
{ id: "a1", name: "Alice" },
{ id: "a2", name: "Alyce" },
{ id: "s1", name: "Smith" },
]
match
@phonetic.deduplicate_names(
records,
example_config(),
[@phonetic.Soundex],
true,
) {
Err(_) => println("deduplication failed")
Ok(report) => {
for group in report.groups {
let mut member_ids = ""
for index = 0; index < group.members.length(); index = index + 1 {
if index > 0 {
member_ids = member_ids + ","
}
member_ids = member_ids + group.members[index].id
}
println(
"representative=\{group.representative.id} members=\{member_ids}",
)
}
for singleton in report.singletons {
println("singleton=\{singleton.id}")
}
println("candidates=\{report.summary.candidate_pair_count}")
println("comparisons=\{report.summary.comparison_count}")
println("accepted=\{report.summary.accepted_edge_count}")
println("groups=\{report.summary.group_count}")
}
}
}