Add match_addresses returning the winning address pair with alignment detail - #278
Merged
Conversation
… detail The list×list address comparison now keeps the winner's bound token pairs in a reused scratch buffer and exposes them as an AddressMatch: score, the raw query and result strings that won, and a one-line diff-style detail (aligned tokens, `q~r` for fuzzy or alias pairs, `-tok` / `+tok` for one-sided residue). compare_address and compare_address_many share the same loop and keep returning the score. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
rigour.addresses.match_addresses(queries, results) -> AddressMatch | Nonereturns the best pair of a list×list address comparison with the evidence behind it:score, the rawqueryandresultstrings that won, and a one-linedetail.detailis a diff-style token line: aligned tokens in query order (berlin,boulevard~blvdfor fuzzy / keyword-alias / territory-code pairs), then-tokfor query-only and+tokfor result-only tokens. Example:sunset boulevard~blvd 12 -los -angeles +la.compare_addressandcompare_address_manyshare the same inner loop and keep returning only the score. Scores are unchanged.This lets nomenklatura's
_address_matchfillFtResult(score, detail, query, candidate)from one call instead of rebuilding its own detail text.Test plan
cargo test,cargo clippy --all-targets -- -D warnings(with and without--features python),cargo fmt --checkpytest --cov rigour(535 passed),mypy --strict rigourmkdocs build --strictcontrib/address_bench/evaluate.py --scorer rust: AUC 0.936, best threshold 0.292 (matches the documented ~0.3)🤖 Generated with Claude Code