Files
resume-agent/backend/app/job_rubric.py
T

145 lines
4.1 KiB
Python

"""Position-anchored dimension weights for deterministic gap evaluation."""
from __future__ import annotations
_OPTIONAL_DIM_DEFAULTS = {
"project_context": 1,
"business_context": 1,
"academic_result": 1,
"project_or_activity": 1,
"team_scope": 1,
"organization_scope": 1,
}
_WEIGHT_TABLE: dict[str, dict[str, int]] = {
"tech": {
"personal_contribution": 3,
"responsibility_scope": 2,
"method_or_technology": 3,
"business_action": 1,
"outcome_or_delivery": 2,
"quantified_outcome": 2,
"coursework_or_practice": 2,
"relevant_capability": 2,
"work_or_solution": 3,
"activity_execution": 1,
"collaboration_scope": 1,
**_OPTIONAL_DIM_DEFAULTS,
},
"data": {
"personal_contribution": 2,
"responsibility_scope": 2,
"method_or_technology": 3,
"business_action": 2,
"outcome_or_delivery": 2,
"quantified_outcome": 3,
"coursework_or_practice": 2,
"relevant_capability": 2,
"work_or_solution": 2,
"activity_execution": 1,
"collaboration_scope": 1,
**_OPTIONAL_DIM_DEFAULTS,
},
"product": {
"personal_contribution": 3,
"responsibility_scope": 2,
"method_or_technology": 1,
"business_action": 3,
"outcome_or_delivery": 3,
"quantified_outcome": 2,
"coursework_or_practice": 1,
"relevant_capability": 2,
"work_or_solution": 2,
"activity_execution": 2,
"collaboration_scope": 3,
**{**_OPTIONAL_DIM_DEFAULTS, "business_context": 2},
},
"design": {
"personal_contribution": 3,
"responsibility_scope": 2,
"method_or_technology": 2,
"business_action": 1,
"outcome_or_delivery": 3,
"quantified_outcome": 1,
"coursework_or_practice": 2,
"relevant_capability": 2,
"work_or_solution": 2,
"activity_execution": 1,
"collaboration_scope": 2,
**_OPTIONAL_DIM_DEFAULTS,
},
"business": {
"personal_contribution": 2,
"responsibility_scope": 3,
"method_or_technology": 1,
"business_action": 3,
"outcome_or_delivery": 3,
"quantified_outcome": 2,
"coursework_or_practice": 1,
"relevant_capability": 2,
"work_or_solution": 1,
"activity_execution": 2,
"collaboration_scope": 3,
**{**_OPTIONAL_DIM_DEFAULTS, "business_context": 2},
},
"default": {
"personal_contribution": 2,
"responsibility_scope": 2,
"method_or_technology": 2,
"business_action": 2,
"outcome_or_delivery": 2,
"quantified_outcome": 2,
"coursework_or_practice": 1,
"relevant_capability": 1,
"work_or_solution": 2,
"activity_execution": 1,
"collaboration_scope": 1,
**_OPTIONAL_DIM_DEFAULTS,
},
}
_ALIASES: dict[str, str] = {
"后端": "tech",
"前端": "tech",
"工程师": "tech",
"开发": "tech",
"算法": "tech",
"测试": "tech",
"运维": "tech",
"数据": "data",
"分析师": "data",
"bi": "data",
"产品": "product",
"运营": "product",
"增长": "product",
"设计": "design",
"ui": "design",
"ux": "design",
"视觉": "design",
"市场": "business",
"销售": "business",
"财务": "business",
"审计": "business",
"人力": "business",
"行政": "business",
"客户成功": "business",
"咨询": "business",
}
def position_family(target_position: str | None) -> str:
"""Return the deterministic rubric family for a confirmed target position."""
text = str(target_position or "").strip().casefold()
if not text:
return "default"
for keyword, family in _ALIASES.items():
if keyword in text:
return family
return "default"
def dimension_weights(target_position: str | None) -> dict[str, int]:
"""Return a copy so callers cannot mutate the module-level weight matrix."""
return dict(_WEIGHT_TABLE[position_family(target_position)])