mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-12 13:29:04 +00:00
Rank historic EPC records by address similarity 🟩
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
d41eb84530
commit
d084a0a785
1 changed files with 25 additions and 1 deletions
|
|
@ -66,7 +66,31 @@ def rank_historic_epc(
|
|||
"""Score ``records`` against ``user_address`` (best first), keeping every
|
||||
record — including hard-zero non-matches. The pure scoring half of the
|
||||
historic-EPC lookup: no I/O, so it is unit-testable without S3."""
|
||||
raise NotImplementedError
|
||||
if not user_address:
|
||||
raise ValueError("user_address must be non-empty")
|
||||
if not records:
|
||||
return []
|
||||
|
||||
df = pd.DataFrame(
|
||||
{
|
||||
address_column: [r.address for r in records],
|
||||
uprn_column: [r.uprn for r in records],
|
||||
}
|
||||
)
|
||||
scored = rank_address_similarity(
|
||||
df,
|
||||
user_address=user_address,
|
||||
address_column=address_column,
|
||||
uprn_column=uprn_column,
|
||||
)
|
||||
return [
|
||||
ScoredHistoricEpc(
|
||||
record=records[i],
|
||||
lexiscore=float(row["lexiscore"]),
|
||||
lexirank=int(row["lexirank"]),
|
||||
)
|
||||
for i, row in scored.iterrows()
|
||||
]
|
||||
|
||||
|
||||
def _sanitise_postcode(postcode: str) -> str:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue