Metadata-Version: 2.4
Name: talent-lens
Version: 0.1.0
Summary: 慧眼 - 候选人简历质量评估系统，从高校背景、大厂经历、职业稳定性、资深程度、学历五个维度进行量化评分
Author-email: Chandler <275737875@qq.com>
License-Expression: MIT
Keywords: recruitment,resume,evaluation,talent,assessment
Classifier: Development Status :: 4 - Beta
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: click>=8.0
Requires-Dist: rich>=12.0
Requires-Dist: pyyaml>=6.0
Requires-Dist: llmdog>=0.1.0

# talent-lens (慧眼)

候选人简历质量评估系统 —— 从高校背景、大厂经历、职业稳定性、资深程度、学历五个维度对候选人进行量化评分并输出综合加权总分。

## 功能特性

- **五维度评估**：高校背景（C9/985/211）、大厂经历（科技/金融/外资科技）、职业稳定性（5年3跳/一年一跳检测）、资深程度、学历
- **多种匹配算法**：精确匹配、别名匹配、模糊匹配（子串包含）
- **LLM 辅助识别**：通过 llmdog 库调用大语言模型，从非结构化简历文本中提取结构化信息
- **灵活配置**：YAML 配置文件支持深度合并，可自定义权重、评分规则、高校/大厂名单
- **双接口**：CLI 命令行 + Python API
- **Rich 终端输出**：表格化评估报告，也支持纯 JSON 输出

## 安装

```bash
pip install talent-lens
```

从源码安装：

```bash
git clone https://github.com/talent-lens/talent-lens.git
cd talent-lens
pip install -e .
```

## 快速开始

### CLI 使用

#### 基本评估

```bash
# 使用内联参数
talent-lens evaluate --name "张三" --university 清华大学 --degree 硕士 --company 阿里巴巴 --work-duration 36 --work-duration 24

# 从 JSON 文件加载
talent-lens evaluate --input candidate.json

# 输出 JSON 格式
talent-lens evaluate --input candidate.json --json

# 输出到文件
talent-lens evaluate --input candidate.json --output result.json
```

#### 候选人 JSON 文件格式

```json
{
  "name": "张三",
  "universities": ["清华大学", "北京大学"],
  "degree": "硕士",
  "companies": [
    {"name": "阿里巴巴", "duration_months": 36},
    {"name": "腾讯", "duration_months": 24}
  ],
  "work_durations": [36, 24],
  "total_work_months": 60
}
```

#### 启用 LLM 辅助识别

```bash
# 设置 API Key
export TALENT_LENS_LLM_API_KEY="your-api-key"

# 启用 LLM
talent-lens evaluate --input candidate.json --resume resume.txt --llm
```

#### 初始化配置文件

```bash
# 生成默认配置文件
talent-lens init

# 强制覆盖已有配置
talent-lens init --force
```

### Python API 使用

```python
from talent_lens import Evaluator, load_config

# 加载配置（自动合并默认配置和用户配置）
config = load_config()

# 创建评估器
evaluator = Evaluator(config)

# 候选人信息
candidate = {
    "name": "张三",
    "universities": ["清华大学"],
    "degree": "硕士",
    "companies": [
        {"name": "阿里巴巴", "duration_months": 36},
        {"name": "腾讯", "duration_months": 24}
    ],
    "work_durations": [36, 24],
    "total_work_months": 60,
}

# 执行评估
result = evaluator.evaluate(candidate)

# 获取结果
print(f"总分: {result['total_score']}")
print(f"各维度分数: {result['dimension_scores']}")
print(f"高校背景: {result['dimensions']['university']}")
```

#### 自定义配置

```python
from talent_lens import Evaluator

# 直接传入配置字典
config = {
    "weights": {
        "university": 30,
        "company": 30,
        "stability": 15,
        "seniority": 15,
        "education": 10,
    },
    "university_scoring": {"c9": 100, "other_985": 85, "other_211": 70, "other": 50, "unknown": 30},
    "company_scoring": {"tech": 100, "foreign_tech": 95, "finance": 80, "other": 50, "unknown": 30},
    "stability_scoring": {
        "levels": {
            "very_stable": {"min_months": 36, "score": 100},
            "stable": {"min_months": 24, "score": 80},
            "moderate": {"min_months": 18, "score": 60},
            "frequent": {"min_months": 12, "score": 40},
            "very_frequent": {"min_months": 0, "score": 20},
        },
        "penalties": {"five_years_three_jumps": -15, "one_year_one_jump": -25},
    },
    "seniority_scoring": {
        "levels": {
            "senior": {"min_years": 8, "score": 100},
            "mid_senior": {"min_years": 5, "score": 75},
            "mid": {"min_years": 3, "score": 50},
            "junior": {"min_years": 1, "score": 30},
            "fresh": {"min_years": 0, "score": 15},
        },
    },
    "education_scoring": {"phd": 100, "master": 80, "bachelor": 60, "associate": 40, "unknown": 30},
}

evaluator = Evaluator(config)
result = evaluator.evaluate(candidate)
```

## 配置说明

### 配置文件

执行 `talent-lens init` 会在当前目录生成 `.talent-lens.yaml`，只需修改需要覆盖的配置项：

```yaml
# 调整权重（总和必须为 100）
weights:
  university: 30
  company: 30
  stability: 15
  seniority: 15
  education: 10

# 调整高校评分
university_scoring:
  c9: 100
  other_985: 85

# 启用 LLM
llm:
  enabled: true
```

### 默认权重

| 维度 | 权重 |
|------|------|
| 高校背景 | 25% |
| 大厂经历 | 25% |
| 职业稳定性 | 20% |
| 资深程度 | 15% |
| 学历 | 15% |

### 评分规则

| 维度 | 分类 | 分数 |
|------|------|------|
| 高校 | C9 | 100 |
| 高校 | 其他985 | 85 |
| 高校 | 其他211 | 70 |
| 高校 | 未知 | 30 |
| 大厂 | 科技 | 100 |
| 大厂 | 外资科技 | 95 |
| 大厂 | 金融 | 80 |
| 大厂 | 未知 | 30 |
| 稳定性 | 非常稳定(>=36月) | 100 |
| 稳定性 | 稳定(>=24月) | 80 |
| 稳定性 | 一般(>=18月) | 60 |
| 稳定性 | 频繁(>=12月) | 40 |
| 稳定性 | 非常频繁(<12月) | 20 |
| 资深 | 资深(>=8年) | 100 |
| 资深 | 中高级(>=5年) | 75 |
| 资深 | 中级(>=3年) | 50 |
| 资深 | 初级(>=1年) | 30 |
| 资深 | 应届(<1年) | 15 |
| 学历 | 博士 | 100 |
| 学历 | 硕士 | 80 |
| 学历 | 本科 | 60 |
| 学历 | 大专 | 40 |
| 学历 | 未知 | 30 |

### 稳定性惩罚

- **5年3跳**：60个月窗口内跳槽超过3次，额外扣15分
- **一年一跳**：连续2段及以上工作经历均不超过12个月，额外扣25分
- 两项惩罚可叠加，扣分后分数不低于0

## 依赖项

- Python >= 3.9
- click >= 8.0（CLI 框架）
- rich >= 12.0（终端格式化）
- pyyaml >= 6.0（YAML 配置解析）
- llmdog >= 0.1.0（LLM 服务调用）

## 许可证

MIT License
