Snapshot before the quality program (relevance gates, tiered mapping, QA linter). v1 is the immutable before/after reference; evidence crawl was at ~175/3039 occupations when tagged. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PDKeXvpT6tENSvyQGLV1Uq
48 lines
1.6 KiB
Python
48 lines
1.6 KiB
Python
"""Phase 6 — white/blue-collar classification per package.
|
|
|
|
Adds to every manifest.json:
|
|
"collar": "white" | "service" | "blue"
|
|
"computer_work": true|false (white collar = computer as primary work tool)
|
|
|
|
Rule (standard ISCO major-group mapping):
|
|
ISCO 1-4 -> white (managers, professionals, technicians, clerical)
|
|
ISCO 5 -> service (services & sales — customer-facing, partly digital)
|
|
ISCO 0,6-9 -> blue (military, agriculture, trades, operators, elementary)
|
|
|
|
Idempotent; runs in seconds. The evidence stage sorts white first (see
|
|
batch_run.stage_evidence) so market data lands where agents help most.
|
|
"""
|
|
import json
|
|
import os
|
|
|
|
SKILLS_DIR = os.path.join(os.path.dirname(__file__), "..", "skills")
|
|
|
|
|
|
def collar_for(isco: str):
|
|
g = (str(isco) or "")[:1]
|
|
if g in "1234":
|
|
return "white", True
|
|
if g == "5":
|
|
return "service", False
|
|
return "blue", False
|
|
|
|
|
|
def main():
|
|
counts = {"white": 0, "service": 0, "blue": 0}
|
|
for slug in sorted(os.listdir(SKILLS_DIR)):
|
|
mp = os.path.join(SKILLS_DIR, slug, "manifest.json")
|
|
if not os.path.isfile(mp):
|
|
continue
|
|
m = json.load(open(mp, encoding="utf-8"))
|
|
collar, computer = collar_for(m.get("ids", {}).get("isco_group"))
|
|
if m.get("collar") != collar or m.get("computer_work") != computer:
|
|
m["collar"] = collar
|
|
m["computer_work"] = computer
|
|
json.dump(m, open(mp, "w", encoding="utf-8"), indent=2)
|
|
counts[collar] += 1
|
|
print("collar classification:", counts)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|