GameTheory Claude Sonnet 4.6 commited on
Commit
2562218
·
1 Parent(s): 15a5be1

fix: correct tomorrow/today mobile library village listing

Browse files

- Fingerprint routes by village names not time strings — eliminates
duplicate route entries caused by minor time-format differences
- Deduplicate villages in today/tomorrow response (Kempsey has 4 stops
but should appear once in a "which places" answer)
- Fix littleworth.md malformed stop table (all stops collapsed into one
cell during crawl) — now matches the correct 9-stop route
- Response now lists all unique villages instead of a single example

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Files changed (2) hide show
  1. query_tool.py +22 -11
  2. wiki/mobile-library/littleworth.md +9 -1
query_tool.py CHANGED
@@ -180,7 +180,9 @@ class WikiIndex:
180
  date_op = _extract_date_op(page["body"])
181
  if date_op:
182
  stops = _parse_stops_from_body(page["body"])
183
- fingerprint = stops[:4]
 
 
184
  if fingerprint and fingerprint not in self._route_registry:
185
  self._route_registry[fingerprint] = {
186
  "date_op": date_op,
@@ -450,17 +452,26 @@ class LibraryQueryTool:
450
  "To find your village's next visit, ask: "
451
  "*\"When does the mobile library visit [your village]?\"*"
452
  )
453
- seen: dict[str, str] = {}
 
 
454
  for route in day_routes:
455
- if route["date_op"] not in seen:
456
- seen[route["date_op"]] = route["sample_village"]
457
- lines = [f"**Mobile Library — {day_label}** ({len(seen)} route{'s' if len(seen) > 1 else ''})\n"]
458
- for pattern, village in sorted(seen.items()):
459
- lines.append(f"- **{pattern}** (e.g. {village})")
460
- lines.append(
461
- "\nTo check if the library visits *your* village, ask: "
462
- "*\"When does the mobile library visit [your village]?\"*"
463
- )
 
 
 
 
 
 
 
464
  return "\n".join(lines)
465
 
466
  # Upcoming dates for a specific month or the next 2 months
 
180
  date_op = _extract_date_op(page["body"])
181
  if date_op:
182
  stops = _parse_stops_from_body(page["body"])
183
+ # Fingerprint by village names only (not times) so minor time-format
184
+ # differences across pages don't create duplicate route entries.
185
+ fingerprint = tuple(s[1] for s in stops[:4])
186
  if fingerprint and fingerprint not in self._route_registry:
187
  self._route_registry[fingerprint] = {
188
  "date_op": date_op,
 
452
  "To find your village's next visit, ask: "
453
  "*\"When does the mobile library visit [your village]?\"*"
454
  )
455
+ # Collect unique villages (order-preserving) across all routes running today
456
+ seen_villages: set[str] = set()
457
+ all_villages: list[str] = []
458
  for route in day_routes:
459
+ route_villages = [s[1] for s in route["stops"] if s[1]]
460
+ if not route_villages:
461
+ route_villages = [route["sample_village"]]
462
+ for v in route_villages:
463
+ if v not in seen_villages:
464
+ seen_villages.add(v)
465
+ all_villages.append(v)
466
+
467
+ n = len(day_routes)
468
+ lines = [
469
+ f"**Mobile Library — {day_label}** ({n} route{'s' if n != 1 else ''} operating)\n",
470
+ f"Villages served on {day_label}:\n",
471
+ ", ".join(all_villages),
472
+ "\nFor times at a specific village, ask: "
473
+ "*\"When does the mobile library visit [your village]?\"*",
474
+ ]
475
  return "\n".join(lines)
476
 
477
  # Upcoming dates for a specific month or the next 2 months
wiki/mobile-library/littleworth.md CHANGED
@@ -17,7 +17,15 @@ last_crawled: "2026-06-07"
17
 
18
  | Time | Village | Stop |
19
  |------|---------|------|
20
- | 11:50am12:05pm | Kempsey | Church Lunch 12:45 to 1pm - Kempsey, Meadow Close1:05 to 1:20pm - Kempsey, Plovers Rise and Adelaide Close1:30 to 1:45pm - Hatfield, Sheraton1:50 to 2:05pm - Littleworth, Orchard Grove |
 
 
 
 
 
 
 
 
21
 
22
  ---
23
  > **Source:** [https://www.worcestershire.gov.uk/council-services/libraries/your-library-membership/mobile-library/littleworth](https://www.worcestershire.gov.uk/council-services/libraries/your-library-membership/mobile-library/littleworth)
 
17
 
18
  | Time | Village | Stop |
19
  |------|---------|------|
20
+ | 9:40am10am | Crowle | Village Hall |
21
+ | 10:30am–10:45am | Kinnersley | The Royal Oak |
22
+ | 10:50am–11:05am | Severn Stoke | Post Box |
23
+ | 11:15am–11:35am | Kempsey | The Firs |
24
+ | 11:50am–12:05pm | Kempsey | Church *(lunch break follows)* |
25
+ | 12:45pm–1pm | Kempsey | Meadow Close |
26
+ | 1:05pm–1:20pm | Kempsey | Plovers Rise and Adelaide Close |
27
+ | 1:30pm–1:45pm | Hatfield | Sheraton |
28
+ | 1:50pm–2:05pm | Littleworth | Orchard Grove |
29
 
30
  ---
31
  > **Source:** [https://www.worcestershire.gov.uk/council-services/libraries/your-library-membership/mobile-library/littleworth](https://www.worcestershire.gov.uk/council-services/libraries/your-library-membership/mobile-library/littleworth)