Spaces:
Paused
Paused
| """ | |
| school_classifier.py — InternScrapper school tagging module. | |
| Classifies a job by title + company name into university school programs. | |
| Uses word-boundary-aware regex so "java" never matches "javascript". | |
| Each job receives at least one program tag; if nothing clears the threshold | |
| the single top-scoring program is used as a fallback. | |
| """ | |
| import re | |
| # ── School registry ────────────────────────────────────────────────────────── | |
| SCHOOLS: dict[str, dict] = { | |
| "SOLAS": { | |
| "name": "School of Liberal Arts and Sciences", | |
| "programs": [ | |
| "B.Sc. Psychology", | |
| "B.Sc. Environmental Science", | |
| "B.A. Philosophy", | |
| "B.A. Politics and International Relations", | |
| ], | |
| }, | |
| "SOB": { | |
| "name": "School of Business", | |
| "programs": [ | |
| "BBA Digital Marketing", | |
| "BBA Capital Markets", | |
| "BBA Business Intelligence and Data Analytics", | |
| "BBA Finance", | |
| "BBA Human Resources", | |
| "BBA Marketing", | |
| "BBA Business (General)", | |
| "B.Com. Accounting and Commerce", | |
| "B.Com. ACCA International Accounting", | |
| "MBA Data and AI", | |
| "MBA Finance", | |
| "MBA Management", | |
| ], | |
| }, | |
| "SODI": { | |
| "name": "School of Design and Innovation", | |
| "programs": [ | |
| "B.Des. Interior Environments", | |
| "B.Des. Product and Industrial Design", | |
| "B.Des. Transdisciplinary Design", | |
| "B.Des. User Experience", | |
| "B.Des. Communication and New Media", | |
| ], | |
| }, | |
| "SoEPP": { | |
| "name": "School of Economics and Public Policy", | |
| "programs": [ | |
| "B.Sc. Economics with Data Analytics", | |
| "B.Sc. Economics with Development Studies", | |
| "M.A. Public Policy and e-Governance", | |
| ], | |
| }, | |
| "SOCSE": { | |
| "name": "School of Computer Science and Engineering", | |
| "programs": [ | |
| "B.Tech. / B.Sc. Computer Science and Engineering", | |
| "B.Sc. Data Science", | |
| "BCA Computer Applications", | |
| "B.Des. User Experience", | |
| "B.Des. Communication and New Media", | |
| ], | |
| }, | |
| "SOFMCA": { | |
| "name": "School of Film, Media and Creative Arts", | |
| "programs": [ | |
| "B.Sc. Filmmaking", | |
| "B.Sc. Animation, VFX and Gaming", | |
| "B.A. Media and Journalism", | |
| "B.A. Acting", | |
| ], | |
| }, | |
| "SOLaw": { | |
| "name": "School of Law", | |
| "programs": [ | |
| "LL.B. Law", | |
| "B.Sc. Criminology, Cyber Law and Forensic Sciences", | |
| ], | |
| }, | |
| "SOAHP": { | |
| "name": "School of Allied and Healthcare Professions", | |
| "programs": [ | |
| "B.Sc. Cardiac Care Technology", | |
| "B.Sc. Anaesthesia and OT Technology", | |
| "B.Sc. Medical Laboratory Technology", | |
| ], | |
| }, | |
| } | |
| # ── Keyword lists ───────────────────────────────────────────────────────────── | |
| # Keys must exactly match the program names in SCHOOLS["programs"]. | |
| # Values are lowercase-friendly; classify_job() lowercases both text and keywords. | |
| # Matching uses word boundaries so partial substrings don't fire. | |
| PROGRAM_KEYWORDS: dict[str, list[str]] = { | |
| # ══ SOLAS — School of Liberal Arts and Sciences ══════════════════════════ | |
| "B.Sc. Psychology": [ | |
| "psychology", "psychologist", "mental health", "counselor", "counselling", | |
| "counseling", "therapist", "therapy", "cognitive science", "behavioral science", | |
| "clinical psychology", "neuropsychology", "wellness coach", "well-being", | |
| "wellbeing", "social worker", "social work", "occupational therapy", | |
| "organizational psychology", "school counselor", "rehabilitation specialist", | |
| "psychometrics", "behavioral researcher", | |
| ], | |
| "B.Sc. Environmental Science": [ | |
| "environmental science", "ecology", "ecologist", "sustainability", | |
| "climate change", "climate analyst", "conservation", "environmental consultant", | |
| "pollution control", "renewable energy", "GIS analyst", "geoscience", | |
| "green energy", "carbon footprint", "biodiversity", "environmental analyst", | |
| "environmental engineer", "water quality", "waste management", "solar energy", | |
| "environmental policy", "LEED", "carbon credit", "sustainability analyst", | |
| "environment", "environmental", "environmental intern", "environmental internship", | |
| ], | |
| "B.A. Philosophy": [ | |
| "philosophy", "philosophical", "ethics researcher", "ethicist", | |
| "epistemology", "humanities researcher", "liberal arts", "logic analyst", | |
| "sociology", "sociologist", "history", "historian", "historical", | |
| ], | |
| "B.A. Politics and International Relations": [ | |
| "political science", "politics", "international relations", "policy analyst", | |
| "policy research", "diplomat", "diplomacy", "governance", "public affairs", | |
| "foreign affairs", "geopolitics", "think tank", "government relations", | |
| "foreign policy", "political analyst", "international affairs", | |
| "UN intern", "united nations", "parliamentary", "advocacy", | |
| "policy advisor", "political researcher", "research assistant", "research intern", | |
| ], | |
| # ══ SOB — School of Business ══════════════════════════════════════════════ | |
| "BBA Digital Marketing": [ | |
| "digital marketing", "SEO", "SEM", "search engine optimization", "PPC", | |
| "pay per click", "Google ads", "Facebook ads", "social media marketing", | |
| "content marketing", "performance marketing", "email marketing", | |
| "growth hacking", "influencer marketing", "affiliate marketing", | |
| "programmatic advertising", "marketing automation", "social media manager", | |
| "digital advertising", "paid media", "inbound marketing", | |
| ], | |
| "BBA Capital Markets": [ | |
| "capital markets", "equity research", "investment banking", "trading analyst", | |
| "stock market", "securities analyst", "portfolio management", | |
| "wealth management", "derivatives", "fixed income", "Bloomberg terminal", | |
| "asset management", "fund management", "stockbroker", "quantitative analyst", | |
| "quant analyst", "credit analyst", "equity analyst", | |
| ], | |
| "BBA Business Intelligence and Data Analytics": [ | |
| "business intelligence", "BI analyst", "BI developer", "business analyst", | |
| "SQL analyst", "Tableau", "Power BI", "data visualization", "reporting analyst", | |
| "MIS analyst", "market research analyst", "analytics consultant", | |
| "insights analyst", "business analytics", "Looker", "dashboard analyst", | |
| ], | |
| "BBA Finance": [ | |
| "financial analyst", "financial modeling", "FP&A", "financial planning", | |
| "corporate finance", "budgeting analyst", "financial reporting", | |
| "investment analyst", "financial controller", "finance intern", | |
| "fund accounting", "valuation analyst", "M&A analyst", | |
| "private equity", "venture capital", "due diligence", | |
| ], | |
| "BBA Human Resources": [ | |
| "human resources", "HR", "recruiter", "talent acquisition", "people operations", | |
| "HRBP", "HR analyst", "HR intern", "workforce planning", "employee engagement", | |
| "learning and development", "compensation analyst", "payroll analyst", | |
| "organizational development", "HR operations", "talent management", | |
| "HR generalist", "people analytics", | |
| ], | |
| "BBA Marketing": [ | |
| "marketing", "brand management", "brand associate", "marketing coordinator", | |
| "marketing intern", "campaign management", "advertising", "public relations", | |
| "PR executive", "brand strategy", "product marketing", "go-to-market", | |
| "market research", "marketing manager", "brand manager", | |
| ], | |
| "BBA Business (General)": [ | |
| "business development", "operations analyst", "management trainee", | |
| "sales executive", "business operations", "supply chain analyst", | |
| "logistics coordinator", "account manager", "client relations", | |
| "customer success", "CRM analyst", "key account manager", | |
| "strategy analyst", "operations management", "project coordinator", | |
| ], | |
| "B.Com. Accounting and Commerce": [ | |
| "accounting", "accountant", "taxation", "bookkeeping", "auditor", | |
| "chartered accountant", "CA intern", "GST consultant", "tally", | |
| "SAP finance", "cost accounting", "financial accounting", "accounts executive", | |
| "accounts payable", "accounts receivable", "tax analyst", "tax consultant", | |
| "statutory audit", "internal audit", "finance executive", | |
| "banking intern", "insurance analyst", | |
| ], | |
| "B.Com. ACCA International Accounting": [ | |
| "ACCA", "international accounting", "financial reporting", "IFRS", "US GAAP", | |
| "assurance", "external audit", "Big 4", "big four", "transfer pricing", | |
| "forensic accounting", | |
| ], | |
| # MBA Data and AI keywords are intentionally management/product-level, | |
| # not engineering-level — technical ML/AI terms live in SOCSE Data Science. | |
| "MBA Data and AI": [ | |
| "AI strategy", "data science manager", "ML product manager", | |
| "AI product manager", "analytics lead", "head of analytics", | |
| "data platform manager", "MLOps manager", "AI governance", | |
| "data science lead", "analytics director", | |
| ], | |
| "MBA Finance": [ | |
| "investment manager", "portfolio manager", "fund manager", "financial planner", | |
| "CFO", "finance manager", "treasury manager", "financial strategy", | |
| "wealth advisor", "financial services manager", "banking strategy", | |
| "credit risk manager", "asset management director", | |
| ], | |
| "MBA Management": [ | |
| "management consultant", "strategy consultant", "management consulting", | |
| "product manager", "program manager", "general manager", "chief of staff", | |
| "strategic planning", "business strategy", "startup", "entrepreneurship", | |
| "venture", "COO", "operations director", | |
| ], | |
| # ══ SODI — School of Design and Innovation ════════════════════════════════ | |
| # Note: "product designer" intentionally appears in both UX and Product/Industrial | |
| # because the title is ambiguous across software and hardware companies. | |
| "B.Des. User Experience": [ | |
| "ux designer", "user experience designer", "ui/ux", "ui ux", "UX researcher", | |
| "interaction designer", "figma", "prototyping", "wireframing", | |
| "usability testing", "design systems", "HCI", "information architecture", | |
| "user research", "design thinking", "product designer", | |
| ], | |
| "B.Des. Interior Environments": [ | |
| "interior design", "interior designer", "interior decorator", "space design", | |
| "architectural design", "spatial design", "interior architect", | |
| "hospitality design", "retail design", "AutoCAD", "SketchUp", "Revit", | |
| "furniture designer", "space planner", | |
| ], | |
| "B.Des. Communication and New Media": [ | |
| "graphic designer", "graphic design", "communication design", | |
| "visual designer", "brand designer", "typography", "illustrator", | |
| "motion graphics", "motion designer", "visual communication", | |
| "advertising design", "print design", "InDesign", "After Effects", | |
| "creative director", "art director", | |
| ], | |
| "B.Des. Product and Industrial Design": [ | |
| "industrial designer", "industrial design", "3D designer", "CAD designer", | |
| "SolidWorks", "Rhino3D", "manufacturing design", "consumer product design", | |
| "hardware design", "packaging designer", "product designer", | |
| ], | |
| "B.Des. Transdisciplinary Design": [ | |
| "design researcher", "service design", "systems design", "design strategy", | |
| "innovation design", "social innovation", "design lead", "design strategist", | |
| "design", "designer", "design intern", "design internship", "creative intern", | |
| ], | |
| # ══ SoEPP — School of Economics and Public Policy ═════════════════════════ | |
| "B.Sc. Economics with Data Analytics": [ | |
| "economics", "economist", "econometrics", "economic analysis", | |
| "quantitative economics", "economic research", "economic modelling", | |
| "macroeconomics", "microeconomics", "research economist", | |
| ], | |
| "B.Sc. Economics with Development Studies": [ | |
| "development economics", "social development", "international development", | |
| "poverty alleviation", "development studies", "SDG", "rural development", | |
| "development sector", "non-profit", "UNICEF", "World Bank intern", | |
| "development finance", "development", "development intern", | |
| ], | |
| "M.A. Public Policy and e-Governance": [ | |
| "public policy", "policy analyst", "policy research", "governance", | |
| "e-governance", "think tank", "policy advocacy", "regulatory affairs", | |
| "public administration", "policy advisor", "regulatory policy", | |
| "digital governance", "civic tech", "government policy", "policy", | |
| "policy intern", "government", "government intern", "research", | |
| "research intern", "public relations", "public relations intern", | |
| ], | |
| # ══ SOCSE — School of Computer Science and Engineering ════════════════════ | |
| "B.Tech. / B.Sc. Computer Science and Engineering": [ | |
| "software", "developer", "engineer", "programmer", "coder", "coding", "cs", "computer science", | |
| "cyber", "security", "qa", "frontend", "backend", "fullstack", "full stack", "cloud", "devops", | |
| "sde", "swe", "it", "web development", "app development", "mobile development", "android", "ios", | |
| "react", "node", "python", "java", "c++", "golang", "flutter", "aws", "azure", "gcp", | |
| "testing", "blockchain", "web3", "systems engineer", "network engineer", "site reliability", "sre", | |
| "hardware", "embedded", | |
| "software engineer", "software developer", "SWE", "SDE", | |
| "backend developer", "backend engineer", "frontend developer", | |
| "frontend engineer", "full stack", "fullstack", "full-stack developer", | |
| "web developer", "web engineer", "python developer", "java developer", | |
| "node.js developer", "react developer", "angular developer", | |
| "DevOps engineer", "cloud engineer", "platform engineer", | |
| "site reliability engineer", "SRE", "embedded engineer", | |
| "systems engineer", "mobile developer", "iOS developer", "android developer", | |
| "Flutter developer", "React Native developer", "engineering intern", | |
| "software intern", "developer intern", "tech intern", | |
| "QA engineer", "quality assurance engineer", "security engineer", | |
| "blockchain developer", "game programmer", "React JS Developer" | |
| ], | |
| "B.Sc. Data Science": [ | |
| "data", "ml", "ai", "artificial intelligence", "machine learning", "analytics", "nlp", | |
| "data analyst", "data engineer", "data science", "computer vision", "quality assurance", | |
| "data scientist", "machine learning engineer", "ML engineer", | |
| "AI engineer", "deep learning", "natural language processing", "NLP engineer", | |
| "computer vision engineer", "neural network", "predictive modeling", | |
| "feature engineering", "TensorFlow", "PyTorch", "scikit-learn", | |
| "data analyst", "data engineer", "ETL developer", "data pipeline", | |
| "data mining", "statistical modeling", "machine learning", | |
| "artificial intelligence", "generative AI", "React JS Developer" | |
| ], | |
| "BCA Computer Applications": [ | |
| "computer applications", "IT support engineer", "technical support", | |
| "system administrator", "network administrator", "database administrator", | |
| "DBA intern", "IT intern", "help desk", "desktop support", "React JS Developer" | |
| ], | |
| # ══ SOFMCA — School of Film, Media and Creative Arts ══════════════════════ | |
| "B.Sc. Filmmaking": [ | |
| "filmmaker", "film director", "cinematographer", "film production", | |
| "video production", "video editor", "post-production", "DOP", | |
| "screenwriter", "scriptwriter", "storyboard artist", "documentary filmmaker", | |
| "cinematography", "production assistant", "film crew", | |
| ], | |
| "B.Sc. Animation, VFX and Gaming": [ | |
| "animator", "2D animator", "3D animator", "VFX artist", "visual effects", | |
| "3D artist", "game designer", "game developer", "Unity developer", | |
| "Unreal Engine developer", "motion capture", "character rigger", | |
| "concept artist", "gaming", "3D animation", "compositing artist", | |
| "Blender", "Maya", "ZBrush", "level designer", "game artist", | |
| ], | |
| "B.A. Media and Journalism": [ | |
| "journalist", "reporter", "news writer", "content writer", "copywriter", | |
| "content creator", "editorial", "broadcast journalist", "media relations", | |
| "communications executive", "digital media", "social media executive", | |
| "news anchor", "sub-editor", "online media", "media analyst", | |
| ], | |
| "B.A. Acting": [ | |
| "actor", "actress", "theatre", "stage performer", "casting coordinator", | |
| "performing arts", "drama teacher", "voice artist", "voice over artist", | |
| "screen acting", | |
| ], | |
| # ══ SOLaw — School of Law ════════════════════════════════════════════════ | |
| "LL.B. Law": [ | |
| "legal intern", "law intern", "paralegal", "lawyer", "attorney", | |
| "legal researcher", "legal analyst", "corporate law", "legal counsel", | |
| "in-house counsel", "associate lawyer", "legal associate", "law clerk", | |
| "legal compliance officer", "contract management", "intellectual property", | |
| "corporate counsel", "legal advisory", "legal officer", "litigation", | |
| "legal drafting", "law", "legal", "lawyer", "advocate", "court", | |
| "legal internship", "law internship", "law/legal", "legal compliance-intern", | |
| "compliance internship", | |
| ], | |
| "B.Sc. Criminology, Cyber Law and Forensic Sciences": [ | |
| "cyber law", "cybersecurity analyst", "forensic analyst", "digital forensics", | |
| "criminology", "crime analyst", "forensic science", "cybercrime investigator", | |
| "privacy law", "data protection officer", "GDPR compliance", | |
| "security analyst", "cyber compliance", "incident response analyst", | |
| "threat intelligence analyst", "infosec", "information security", | |
| ], | |
| # ══ SOAHP — School of Allied and Healthcare Professions ══════════════════ | |
| "B.Sc. Cardiac Care Technology": [ | |
| "cardiac technician", "cardiology technician", "ECG technician", | |
| "echocardiography", "cardiac catheterization", "cardiovascular technician", | |
| "cardiac care", "Holter monitoring", "cardiac sonographer", | |
| ], | |
| "B.Sc. Anaesthesia and OT Technology": [ | |
| "anaesthesia technician", "anesthesia technician", | |
| "operation theatre technician", "OT technician", "surgical technician", | |
| "perioperative technician", "scrub technician", "OT assistant", | |
| ], | |
| "B.Sc. Medical Laboratory Technology": [ | |
| "medical laboratory technician", "lab technician", "clinical laboratory", | |
| "pathology laboratory", "microbiology technician", "hematology technician", | |
| "phlebotomist", "medical lab technician", "biochemistry technician", | |
| "blood bank technician", "histopathology", "healthcare", "medical", | |
| "clinical", "laboratory", "nursing", "public health", "clinical research", | |
| "hospital administration", "pharma", "nurse", "pharmaceutical", "health", | |
| "healthcare intern", "medical intern", "nursing intern", "pharma intern", | |
| ], | |
| } | |
| # ── Module-level invariant check ────────────────────────────────────────────── | |
| _registered = {p for data in SCHOOLS.values() for p in data["programs"]} | |
| _keyed = set(PROGRAM_KEYWORDS.keys()) | |
| assert _registered == _keyed, ( | |
| f"SCHOOLS/PROGRAM_KEYWORDS mismatch — missing keys: {_registered ^ _keyed}" | |
| ) | |
| # ── Pre-compiled patterns (built once at import) ────────────────────────────── | |
| # Uses negative lookbehind/lookahead for \w so "java" never fires on "javascript" | |
| # and "sql" never fires on "mysql". | |
| _COMPILED: dict[str, list[re.Pattern[str]]] = { | |
| prog: [ | |
| re.compile(r"(?<!\w)" + re.escape(kw.lower()) + r"(?!\w)") | |
| for kw in keywords | |
| ] | |
| for prog, keywords in PROGRAM_KEYWORDS.items() | |
| } | |
| # ── Program → school lookup ─────────────────────────────────────────────────── | |
| _PROG_TO_SCHOOL: dict[str, list[str]] = {} | |
| for code, data in SCHOOLS.items(): | |
| for prog in data["programs"]: | |
| if prog not in _PROG_TO_SCHOOL: | |
| _PROG_TO_SCHOOL[prog] = [] | |
| _PROG_TO_SCHOOL[prog].append(code) | |
| # ── Public API ──────────────────────────────────────────────────────────────── | |
| def classify_job(title: str, company: str, threshold: int = 1) -> dict: | |
| """Return matched programs and parent schools for a job. | |
| Args: | |
| title: Job title (may be None — handled gracefully). | |
| company: Company name (may be None — handled gracefully). | |
| threshold: Minimum keyword-hit count to count as a match. Default 1. | |
| Returns: | |
| { | |
| "programs": list[str], # matched program names, score-descending | |
| "schools": list[str], # unique parent school codes, insertion-ordered | |
| } | |
| """ | |
| text = f"{title or ''} {company or ''}".lower() | |
| scores: dict[str, int] = { | |
| prog: sum(1 for pat in patterns if pat.search(text)) | |
| for prog, patterns in _COMPILED.items() | |
| } | |
| matched = [p for p, s in scores.items() if s >= threshold] | |
| # Sort matched programs by score descending so the best fits appear first. | |
| matched.sort(key=lambda p: scores[p], reverse=True) | |
| # Deduplicated school codes, preserving matched order. | |
| schools = [] | |
| for p in matched: | |
| for school_code in _PROG_TO_SCHOOL[p]: | |
| if school_code not in schools: | |
| schools.append(school_code) | |
| return {"programs": matched, "schools": schools} | |