From f02cabc94fcb5cf96c629dce12df3c90d755c16f Mon Sep 17 00:00:00 2001 From: SecureCloudGroup Date: Mon, 28 Sep 2026 13:25:55 -0400 Subject: [PATCH] Parity with the app's port: ZIP is a location, generic time words, likeliest readings first - a ZIP code lifts location-capable sources like a city does; it no longer narrows candidates as a subject - day/week/hourly/data and similar time words are never what the user wants - an ambiguous match lists the largest places (then the most popular entries) first Evaluations unchanged: resolvers 60/60 + 44/44; lookup 45/45, 38/40, 30/30. --- sourcetool/build.py | 2 +- sourcetool/resolve.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/sourcetool/build.py b/sourcetool/build.py index 64798a9..f5c1dd2 100644 --- a/sourcetool/build.py +++ b/sourcetool/build.py @@ -205,7 +205,7 @@ def _load_resolvers(con) -> int: # A resolver whose names overlap ordinary place names (an airport called "Boise") counts only with a cue in # the ask — a code typed like a code, or one of its words. ENTITY_RESOLVERS = ("team_mlb", "team_nhl", "team_espn", "ticker", "crypto", "currency", "airport", "statuspage", - "soccer_competition", "fr_agency", "spending_agency", "zip") + "soccer_competition", "fr_agency", "spending_agency") # a ZIP is a location, not a subject ENTITY_CUES = { "airport": {"airport", "airports", "flight", "flights", "delay", "delays", "delayed", "tsa", "ground", "gate", "departures", "arrivals", "runway"}, diff --git a/sourcetool/resolve.py b/sourcetool/resolve.py index 64883b1..08990c9 100644 --- a/sourcetool/resolve.py +++ b/sourcetool/resolve.py @@ -30,6 +30,8 @@ weather forecast status down up is are open closed news report delays delay rate rates level levels air quality index time times tide tides high low sunset sunrise map chart live new top best any all list value city town county state station buoy airport near around local home work traffic bus train subway flight flights +day days daily hour hours hourly minute minutes week weekly month monthly year yearly date info information +data update updates """.split()) @@ -141,6 +143,8 @@ def by_name(resolver: str, ask: str, *, raw_case_codes: bool = True, many: bool "reason": f"{pops[0][1]['name']} is by far the largest of {len(ties)} places with that name"} distinct = {(t["name"], t.get("state"), json.dumps(t.get("attrs", {}).get("league"))) for t in ties} if len(ties) > 1 and len(distinct) > 1 and not _same_thing(ties): + # offer the likeliest readings first: the largest places, the most popular teams/assets + ties = sorted(all_ties, key=lambda t: (-(t.get("attrs", {}).get("pop") or 0), -float(t.get("rank") or 0)))[:6] return {"status": "ambiguous", "best": None, "candidates": ties, "reason": "several match equally: " + "; ".join(_label(t) for t in ties)} return {"status": "resolved", "best": top, "candidates": [rows[i] for i, _ in ranked[:5]], "reason": ""}