Skip to content

Add match_addresses returning the winning address pair with alignment detail - #278

Merged
pudo merged 1 commit into
mainfrom
feat/address-match-detail
Sep 3, 2026
Merged

Add match_addresses returning the winning address pair with alignment detail#278
pudo merged 1 commit into
mainfrom
feat/address-match-detail

Conversation

@pudo

@pudo pudo commented Sep 3, 2026

Copy link
Copy Markdown
Member

Summary

  • New rigour.addresses.match_addresses(queries, results) -> AddressMatch | None returns the best pair of a list×list address comparison with the evidence behind it: score, the raw query and result strings that won, and a one-line detail.
  • detail is a diff-style token line: aligned tokens in query order (berlin, boulevard~blvd for fuzzy / keyword-alias / territory-code pairs), then -tok for query-only and +tok for result-only tokens. Example: sunset boulevard~blvd 12 -los -angeles +la.
  • compare_address and compare_address_many share the same inner loop and keep returning only the score. Scores are unchanged.
  • The alignment writes its bound pairs into a reused scratch buffer that is swapped into the winner's slot on improvement, so the hot N×M loop allocates nothing per pair and the detail string is built once, for the winner.

This lets nomenklatura's _address_match fill FtResult(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 --check
  • pytest --cov rigour (535 passed), mypy --strict rigour
  • mkdocs build --strict
  • contrib/address_bench/evaluate.py --scorer rust: AUC 0.936, best threshold 0.292 (matches the documented ~0.3)

🤖 Generated with Claude Code

… 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>
@pudo
pudo merged commit 73fc04b into main Sep 3, 2026
22 checks passed
@pudo
pudo deleted the feat/address-match-detail branch September 3, 2026 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant