Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sourcetool/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down
4 changes: 4 additions & 0 deletions sourcetool/resolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())


Expand Down Expand Up @@ -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": ""}
Expand Down
Loading