classify_sector
Classify municipal bond descriptions into sectors using keyword rules. Verify that the classification is deterministic and consistent.
Instructions
Classify a muni bond issue description into a sector using the same keyword rules the calendar tool uses. Useful to show Marciano the classifier is deterministic, not a black box.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| description | Yes |
Implementation Reference
- server.py:281-288 (handler)The classify_sector function that classifies a muni bond description into a sector using keyword rules (SECTOR_RULES). Returns 'Other / Unclassified' if no keyword matches.
def classify_sector(description: str) -> str: """Classify a muni bond description into a sector. Order matters — more specific rules first (e.g. 'school revenue' → Education not Revenue).""" d = f" {description.lower()} " for sector, keywords in SECTOR_RULES: if any(k in d for k in keywords): return sector return "Other / Unclassified" - server.py:154-182 (helper)SECTOR_RULES list of (sector_name, [keywords]) tuples used by classify_sector. Ordered by specificity with rules for Healthcare, Housing, Education, Water/Utility, Transportation, IDB, Tobacco, Pension, Refunding, GO, and Revenue.
SECTOR_RULES: list[tuple[str, list[str]]] = [ ("Healthcare / Hospital", [ "hospital", "health", "medical center", "healthcare", "nursing", "senior living" ]), ("Housing", [ "housing", "multifamily", "single family", "residential mortgage" ]), ("Education / Schools", [ "school", "district", "education", "university", "college", "student loan" ]), ("Water / Sewer / Utility", [ "water", "sewer", "wastewater", "utility", "electric", "power", "gas system" ]), ("Transportation", [ "transport", "toll", "turnpike", "bridge", "port", "airport", "aviation", "transit", "highway", "road", "metro" ]), ("Industrial Development / IDB", [ "industrial development", "idb", "economic development", "development revenue" ]), ("Tobacco Settlement", ["tobacco"]), ("Pension / OPEB", ["pension", "opeb"]), ("Refunding", ["refunding"]), ("General Obligation", [ "general obligation", " go ", "(go)", "unlimited tax", "limited tax", "school building", "public improvement" ]), ("Revenue", ["revenue"]), ] - server.py:443-456 (schema)Tool registration schema for classify_sector — takes a single required 'description' string parameter. Output is JSON with description and sector fields.
name="classify_sector", description=( "Classify a muni bond issue description into a sector using the same " "keyword rules the calendar tool uses. Useful to show Marciano the " "classifier is deterministic, not a black box." ), inputSchema={ "type": "object", "properties": { "description": {"type": "string"}, }, "required": ["description"], }, ), - server.py:903-905 (registration)Dispatch handler for classify_sector in call_tool/_dispatch. Extracts 'description' from args and returns {'description': ..., 'sector': classify_sector(desc)}.
if name == "classify_sector": desc = args.get("description", "") return {"description": desc, "sector": classify_sector(desc)}