Metadata-Version: 2.2
Name: talent-birdview
Version: 0.1.0
Summary: A PyPI module for talent insight, org structure, salary analysis and company alias management.
Author-email: Chandler <275737875@qq.com>
License: MIT
Keywords: talent,talent analysis,salary analysis,organization structure,company alias management
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Office/Business
Classifier: Topic :: Scientific/Engineering :: Information Analysis
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pandas>=1.3.0
Requires-Dist: numpy>=1.20.0
Requires-Dist: typer>=0.9.0
Requires-Dist: matplotlib>=3.4.0
Requires-Dist: seaborn>=0.11.0
Requires-Dist: openpyxl>=3.0.0
Requires-Dist: pyyaml>=5.4.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: black>=22.0.0; extra == "dev"
Requires-Dist: flake8>=4.0.0; extra == "dev"

# talent-birdview

人才数据分析工具,基于人才数据，提供人才洞察、组织架构分析、薪酬统计和公司别名标准化等功能。

## 功能特性

- **人才洞察分析**：生成多维度技术人才 Markdown 报告，含地区分布、公司画像、技术方向、高管/核心人才洞察
- **组织架构分析**：基于职位信息自动推断技术层级与汇报关系，生成 Mermaid 组织架构图
- **薪酬统计分析**：解析多种薪酬格式，生成 8 类可视化图表（直方图、箱线图、热力图、散点图等）
- **公司别名生成**：基于自动规则引擎从原始数据中生成公司名称标准化映射
- **公司名称标准化**：内置 270+ 品牌映射与自动匹配规则，支持运行时扩展
- **配置管理系统**：分层配置架构（默认配置 < 自定义配置 < 命令行参数），支持 YAML/JSON

## 安装

```bash
pip install talent-birdview
```

或从源码安装：

```bash
git clone <repo-url>
cd talent-birdview
pip install -e .
```

## 快速开始

### 1. 初始化配置文件

```bash
talent-birdview config init -o ./my_config.yaml
```

编辑 `my_config.yaml`，设置你的数据源文件路径：

```yaml
files:
  具身智能: "./talent01.xlsx"
  自动驾驶: "./autodrive_talent.xlsx"
```

### 2. 执行分析

```bash
# 人才洞察报告
talent-birdview talent --config ./my_config.yaml --output ./talent_report.md

# 组织架构深度分析（含 Mermaid 图）
talent-birdview org --config ./my_config.yaml --output ./org_report.md

# 薪酬统计分析（自动生成图表）
talent-birdview salary --config ./my_config.yaml --output ./salary_report.md --chart-dir ./charts
```

### 3. 生成公司别名映射

```bash
talent-birdview aliases --excel ./autodrive_talent.xlsx --excel ./talent01.xlsx --output ./new_aliases.json --stats
```

## 命令行接口

### 分析命令

| 命令 | 说明 | 示例 |
|------|------|------|
| `talent` | 人才洞察分析 | `talent-birdview talent -c config.yaml -o report.md` |
| `org` | 组织架构分析 | `talent-birdview org -c config.yaml -o org.md` |
| `salary` | 薪酬统计分析 | `talent-birdview salary -c config.yaml --chart-dir ./charts` |
| `aliases` | 别名自动生成 | `talent-birdview aliases -e data.xlsx -o aliases.json` |

### 配置管理

```bash
# 导出默认配置模板
talent-birdview config init -o ./talent_birdview_config.yaml

# 查看完整生效配置
talent-birdview config show -c ./my_config.yaml

# 查看单个配置项
talent-birdview config show -c ./my_config.yaml -k files
```

### 公司名称标准化

```bash
# 单条标准化
talent-birdview company normalize "魔门塔（苏州）科技有限公司"
# 输出: Momenta

# 批量标准化 Excel 中的公司名
talent-birdview company batch ./data.xlsx -o ./normalized.xlsx

# 加载额外的别名映射文件
talent-birdview company normalize "某某科技" -a ./extra_aliases.json
```

## 配置说明

配置采用分层架构，优先级从高到低：

1. **命令行参数**（如 `--chart-dir`）
2. **用户自定义配置文件**（通过 `--config` 指定）
3. **模块内置默认配置**

### 配置项说明

```yaml
# 数据源文件映射
files:
  具身智能: "./talent01.xlsx"
  自动驾驶: "./autodrive_talent.xlsx"

# 输出路径
output:
  talent_report: "./talent_insight_report.md"
  org_report: "./org_structure_report.md"
  salary_report: "./salary_analysis_report.md"
  salary_charts: "./salary_charts"
  aliases_debug: "./new_aliases_debug.txt"

# 分析参数
analysis:
  talent_top_companies: 40        # 人才报告公司分布显示数量
  org_min_people: 15              # 组织架构分析最少技术人才数
  org_max_directions: 8           # Mermaid 图最大技术方向数
  salary_min_company_sample: 10   # 薪酬公司对比最小样本数

# 技术关键词
 tech_keywords: [...]             # 判定技术岗位的白名单关键词
non_tech_keywords: [...]          # 判定非技术岗位的黑名单关键词

# 技术方向映射
tech_direction_map:
  感知: ["感知", "视觉", "激光雷达", ...]
  规划决策: ["规划", "决策", "预测", ...]
  ...
```

## 模块架构

```
talent_birdview/
├── __init__.py          # 包入口
├── __main__.py          # python -m talent_birdview 入口
├── cli.py               # Typer 命令行接口
├── config.py            # 配置管理器 (ConfigManager)
├── company.py           # 公司名称标准化 (CompanyNormalizer)
├── data.py              # 公共数据层 (TalentDataLoader + 工具函数)
├── aliases_data.py      # 内置完整公司别名映射数据
├── templates/
│   └── default_config.yaml   # 默认配置模板
└── analysis/
    ├── __init__.py
    ├── talent.py          # 人才洞察分析 (TalentAnalyzer)
    ├── org.py             # 组织架构分析 (OrgStructureAnalyzer)
    ├── salary.py          # 薪酬统计分析 (SalaryAnalyzer)
    └── aliases.py         # 别名生成 (AliasGenerator)
```

## 作为 Python 库使用

```python
from talent_birdview.config import ConfigManager
from talent_birdview.company import CompanyNormalizer
from talent_birdview.analysis import TalentAnalyzer, SalaryAnalyzer

# 加载配置
cfg = ConfigManager("./my_config.yaml").get_all()

# 标准化公司名
normalizer = CompanyNormalizer()
print(normalizer.normalize("魔门塔（苏州）科技有限公司"))  # Momenta

# 执行人才洞察分析
analyzer = TalentAnalyzer(config=cfg)
report = analyzer.analyze()
with open("./report.md", "w", encoding="utf-8") as f:
    f.write(report)

# 执行薪酬分析
salary_analyzer = SalaryAnalyzer(config=cfg)
report = salary_analyzer.analyze()
```

## 扩展公司名称映射

### 运行时添加

```python
from talent_birdview.company import CompanyNormalizer

n = CompanyNormalizer()
n.add_alias("某某科技有限公司", "某某")
print(n.normalize("某某科技有限公司"))  # 某某
```

### 从文件加载扩展映射

```python
n.load_aliases("./my_aliases.json")
n.save_aliases("./updated_aliases.json")
```

### 自定义自动规则

```python
from talent_birdview.analysis import AliasGenerator

rules = [
    ("新品牌", ["新品牌", "新品牌科技"], ["排除词"]),
]
generator = AliasGenerator(auto_rules=rules)
new_aliases = generator.generate(["./data.xlsx"])
```

## 数据源格式要求

Excel 文件需包含以下列（列名不区分大小写）：

| 列名 | 说明 | 必需 |
|------|------|------|
| `company` | 公司名称 | 是 |
| `position` | 职位名称 | 是 |
| `name` | 姓名 | 否 |
| `city` | 城市 | 否 |
| `province` | 省份 | 否 |
| `salary` | 薪酬（如 35k-45k/月） | 否 |
| `work_time` | 工作年限 | 否 |
| `sdegree` | 学历 | 否 |
| `school` | 毕业院校 | 否 |
| `exp` | 工作经历（JSON 格式） | 否 |

## 依赖

- Python >= 3.9
- pandas
- numpy
- matplotlib
- seaborn
- openpyxl
- typer
- pyyaml

## License

MIT
