Metadata-Version: 2.4
Name: resume-oneclick
Version: 0.1.2
Summary: 简历批量解析工具，支持PDF、DOC、DOCX格式简历的文本提取和信息解析
Author-email: Chandler <275737875@qq.com>
License: MIT
Keywords: resume,parser,pdf,docx,hr,recruitment
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
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 :: Text Processing
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: typer[all]>=0.4.0
Requires-Dist: PyPDF2>=3.0.0
Requires-Dist: pdfplumber>=0.7.0
Requires-Dist: python-docx>=0.8.11
Requires-Dist: openpyxl>=3.0.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
Requires-Dist: twine>=4.0.0; extra == "dev"
Requires-Dist: build>=0.10.0; extra == "dev"

# resume-oneclick

> 简历批量解析工具 —— 一键提取 PDF / DOC / DOCX 简历中的结构化信息

[![PyPI version](https://img.shields.io/pypi/v/resume-oneclick.svg)](https://pypi.org/project/resume-oneclick/)
[![Python Version](https://img.shields.io/pypi/pyversions/resume-oneclick.svg)](https://pypi.org/project/resume-oneclick/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Downloads](https://img.shields.io/pypi/dm/resume-oneclick.svg)](https://pypi.org/project/resume-oneclick/)

---

## 核心特性

- **多格式支持**：PDF、DOC、DOCX 三种常见简历格式全覆盖
- **批量处理**：一次处理整个目录下的所有简历文件
- **智能信息提取**：基于正则表达式与关键词匹配，自动提取姓名、联系方式、学历、学校、专业、技术方向、公司等结构化信息
- **Excel 报告生成**：解析结果一键汇总为带格式的 Excel 报告，支持状态颜色标记
- **TXT 文本转换**：将简历文件批量转换为纯文本，方便后续处理
- **现代化 CLI**：基于 [Typer](https://typer.tiangolo.com/) 框架，提供进度条、彩色输出等友好交互
- **模块化设计**：Extractor / Parser / CLI 三层架构，易于扩展

---

## 快速安装

### 通过 pip 安装（推荐）

```bash
pip install resume-oneclick
```

### 从源码安装

```bash
git clone https://github.com/your-username/resume-oneclick.git
cd resume-oneclick
pip install -e ".[dev]"
```

---

## 使用教程

安装完成后，即可使用 `resume-parser` 命令：

```bash
resume-parser --help
```

输出：

```
 Usage: resume-parser [OPTIONS] COMMAND [ARGS]...

 简历解析工具 - 支持PDF、DOC、DOCX格式简历的批量处理

╭─ Commands ───────────────────────────────────────────╮
│ to-txt  将简历文件转换为TXT文本文件                  │
│ parse   批量解析简历并生成Excel汇总报告              │
╰──────────────────────────────────────────────────────╯
```

### 命令一：to-txt — 批量转换为 TXT

将指定目录下的简历文件（PDF / DOC / DOCX）批量转换为纯文本文件。

**参数说明：**

| 参数 | 缩写 | 说明 | 必填 |
|------|------|------|------|
| `--input` | `-i` | 简历文件所在目录 | 是 |
| `--output` | `-o` | TXT 文件保存目录 | 是 |

**示例：**

```bash
resume-parser to-txt -i ./resumes -o ./txt_output
```

执行后会在 `./txt_output` 目录下为每份简历生成对应的 `.txt` 文件。

### 命令二：parse — 批量解析并生成 Excel 报告

批量解析简历文件，提取结构化信息，并生成 Excel 汇总报告。

**参数说明：**

| 参数 | 缩写 | 说明 | 必填 | 默认值 |
|------|------|------|------|--------|
| `--input` | `-i` | 简历文件所在目录 | 是 | — |
| `--output` | `-o` | Excel 报告保存目录 | 是 | — |
| `--name` | `-n` | Excel 报告文件名 | 否 | `简历信息汇总.xlsx` |

**示例：**

```bash
resume-parser parse -i ./resumes -o ./reports -n 2026春招汇总.xlsx
```

执行后会在 `./reports` 目录下生成带格式的 Excel 报告，包含所有简历的解析结果。

### Python API 调用

除了 CLI 命令，你也可以在 Python 代码中直接使用：

```python
from resume_oneclick import extract_file, extract_resume_info

# 提取简历文本
text, method = extract_file("张三@清华大学.pdf")
print(f"提取方法: {method}")
print(f"文本内容:\n{text[:200]}")

# 解析结构化信息
info = extract_resume_info(text, filename="张三@清华大学.pdf")
print(f"姓名: {info['姓名']}")
print(f"学校: {info['最高学历毕业学校']}")
print(f"专业: {info['最高学历专业']}")
print(f"技术方向: {info['当前投入方向']}")
```

---

## 技术架构

### 项目目录结构

```
resume-oneclick/
├── resume_oneclick/          # 核心包
│   ├── __init__.py           # 包初始化与公共 API 导出
│   ├── extractor.py          # 文件提取器模块
│   ├── parser.py             # 信息解析器模块
│   └── cli.py                # 命令行接口模块
├── setup.py                  # 传统安装配置
├── pyproject.toml            # 现代项目配置
├── requirements.txt          # 依赖清单
├── README.md                 # 项目说明
└── .gitignore                # Git 忽略配置
```

### 模块架构

```
┌─────────────────────────────────────────────────────┐
│                CLI Layer (cli.py)                    │
│             命令行接口层 (Typer 框架)                │
└─────────────────────────────────────────────────────┘
                          │
              ┌───────────┴───────────┐
              ▼                       ▼
┌──────────────────────┐    ┌──────────────────────┐
│  Extractor Module    │    │   Parser Module      │
│  (extractor.py)      │    │   (parser.py)        │
│  文件提取器           │    │   信息解析器          │
└──────────────────────┘    └──────────────────────┘
```

### 数据流向

```
输入文件 (PDF/DOC/DOCX)
        │
        ▼
  ┌─────────────┐
  │  Extractor   │  extract_file() — 提取纯文本
  └─────────────┘
        │
        ▼
    纯文本内容
        │
        ├────────────────┐
        ▼                ▼
  ┌───────────┐  ┌─────────────┐
  │ TXT 输出   │  │   Parser    │  extract_resume_info() — 结构化解析
  └───────────┘  └─────────────┘
                        │
                        ▼
                 结构化信息字典
                        │
                        ▼
                 Excel 报告 / CLI 输出
```

### 设计模式

| 模式 | 应用位置 | 说明 |
|------|----------|------|
| **策略模式** | `extract_file()` | 根据文件扩展名动态选择提取方法 |
| **备用模式** | PDF / DOC 提取 | PDF: pdfplumber → PyPDF2；DOC: python-docx → win32com |
| **模板方法模式** | `extract_resume_info()` | 统一提取流程：初始化 → 姓名 → 联系方式 → 学历 → 技术方向 → 公司 |

### 核心依赖

| 库 | 用途 |
|----|------|
| [typer](https://typer.tiangolo.com/) | 命令行框架 |
| [pdfplumber](https://github.com/jsvine/pdfplumber) | PDF 文本提取（主要方法） |
| [PyPDF2](https://pypdf2.readthedocs.io/) | PDF 文本提取（备用方法） |
| [python-docx](https://python-docx.readthedocs.io/) | DOCX / DOC 文件解析 |
| [openpyxl](https://openpyxl.readthedocs.io/) | Excel 报告生成 |

---

## 支持的简历格式与提取字段

### 文件格式

| 格式 | 扩展名 | 提取引擎 |
|------|--------|----------|
| PDF | `.pdf` | pdfplumber（主）/ PyPDF2（备） |
| DOCX | `.docx` | python-docx（段落 + 表格） |
| DOC | `.doc` | python-docx（主）/ win32com（备，仅 Windows） |

### 可提取字段

| 字段 | 说明 | 提取方式 |
|------|------|----------|
| 姓名 | 候选人姓名 | 文件名模式匹配 + 文本首行识别 |
| 电话号码 | 手机号 / 座机号 | 正则表达式（支持 +86 等多种格式） |
| 邮箱 | 电子邮箱地址 | 正则表达式匹配 |
| 最高学历 | 博士 / 硕士 / 本科等 | 关键词优先级匹配 |
| 最高学历毕业学校 | 毕业院校 | 180+ 所国内外知名高校匹配 |
| 最高学历专业 | 所学专业 | 100+ 个常见专业匹配 |
| 当前投入方向 | 技术方向 / 研究领域 | 60+ 个技术关键词从经历段落提取 |
| 所在公司 | 当前或历史任职公司 | 80+ 家国内外知名企业匹配 |

---

## 开发指南

### 搭建开发环境

推荐使用 **conda** 创建独立的开发环境：

```bash
# 创建 conda 环境
conda create -n pypi python=3.11 -y
conda activate pypi

# 克隆项目
git clone https://github.com/your-username/resume-oneclick.git
cd resume-oneclick

# 以可编辑模式安装（含开发依赖）
pip install -e ".[dev]"
```

或使用 **venv**：

```bash
python -m venv venv
source venv/bin/activate  # macOS/Linux
pip install -e ".[dev]"
```

### 运行测试

```bash
pytest tests/ -v --cov=resume_oneclick
```

### 构建与发布

```bash
# 构建分发包
python -m build

# 上传到 PyPI
twine upload dist/*
```

### 贡献代码

1. Fork 本仓库
2. 创建功能分支：`git checkout -b feature/your-feature`
3. 提交变更：`git commit -m "feat: add your feature"`
4. 推送分支：`git push origin feature/your-feature`
5. 创建 Pull Request

---

## 免责声明

- 本工具 `resume-oneclick` 仅用于合法合规的简历处理场景（如企业招聘、猎头服务等），不得用于任何非法目的。
- 使用者在处理简历数据时，**必须遵守相关数据隐私法律法规**，包括但不限于《中华人民共和国个人信息保护法》、《数据安全法》以及适用的国际隐私法规（如 GDPR）。
- 工具的解析结果基于规则匹配与关键词识别，**仅供参考，不对准确性、完整性做任何保证**。
- 作者不对因使用本工具产生的任何直接、间接或附带的损失、法律责任或数据泄露问题负责。
- 使用者应确保已获得简历所有人的合法授权后再进行数据处理。

---

## License

本项目基于 [MIT License](https://opensource.org/licenses/MIT) 开源。

```
MIT License

Copyright (c) 2026 resume-oneclick contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```
