tanmay-bm commited on
Commit
a0d142e
Β·
1 Parent(s): 6dc647c

fix: taluka entity causing district filter to reject correct college rows

Browse files

'VISNAGAR' was extracted as a taluka entity and used as district filter.
CollegeIntakeMaster stores CollegeDistrict='Mehsana' for Visnagar colleges,
so filtering by 'visnagar' rejected all M. N. COLLEGE, VISNAGAR rows.

Two-part fix:
1. query_planner: only use entity_type='district'|'city' for district filter,
not 'taluka' (talukas often appear inside college names)
2. structured_search: skip district filter entirely when college_name is
resolved β€” the college name is more specific and makes district redundant

Files changed (2) hide show
  1. query_planner.py +5 -2
  2. structured_search.py +5 -1
query_planner.py CHANGED
@@ -294,8 +294,11 @@ def build_query_plan(raw_query: str) -> QueryPlan:
294
  for e in processed.detected_entities:
295
  if e.entity_type == "college" and not college_name:
296
  college_name = e.matched
297
- elif e.entity_type in ("district", "taluka", "city") and not district:
298
- # Use matched canonical name
 
 
 
299
  district = e.matched
300
 
301
  # ── Step 4: Additional entity extractions ────────────────────────────
 
294
  for e in processed.detected_entities:
295
  if e.entity_type == "college" and not college_name:
296
  college_name = e.matched
297
+ elif e.entity_type in ("district", "city") and not district:
298
+ # Only take actual district entities (not taluka) as district filter.
299
+ # Talukas often appear inside college names (e.g. "VISNAGAR" in
300
+ # "M. N. COLLEGE, VISNAGAR") and would cause false mismatches because
301
+ # CollegeDistrict stores the district ("Mehsana"), not the taluka.
302
  district = e.matched
303
 
304
  # ── Step 4: Additional entity extractions ────────────────────────────
structured_search.py CHANGED
@@ -186,7 +186,11 @@ def _row_matches(
186
  return False
187
 
188
  # ── District ──────────────────────────────────────────────────────────
189
- if district:
 
 
 
 
190
  dist = _district(row).lower()
191
  if not dist:
192
  return False
 
186
  return False
187
 
188
  # ── District ──────────────────────────────────────────────────────────
189
+ # Skip district filter when college_name is already resolved β€” the college
190
+ # name uniquely identifies the college and is more specific than district.
191
+ # (Filtering by district would incorrectly drop colleges in a taluka whose
192
+ # name matches the query but whose CollegeDistrict differs from the taluka.)
193
+ if district and not college_name:
194
  dist = _district(row).lower()
195
  if not dist:
196
  return False