67 lines
1.3 KiB
Markdown
67 lines
1.3 KiB
Markdown
# 字段分组Skill 设计
|
|
|
|
## 1. Skill 定位
|
|
|
|
`字段分组Skill` 负责将统一字段池中的字段候选按字段编码和来源文档分组,形成可比对的数据单元。
|
|
|
|
英文实现标识建议使用 `FieldGroupSkill`。
|
|
|
|
## 2. 输入
|
|
|
|
```python
|
|
@dataclass
|
|
class FieldGroupInput:
|
|
field_pool_items: list[FieldPoolItem]
|
|
field_candidates: list[FieldCandidateRecord]
|
|
scope_documents: list[DocumentFact]
|
|
```
|
|
|
|
## 3. 输出
|
|
|
|
```python
|
|
@dataclass
|
|
class FieldGroupOutput:
|
|
compare_units: list[FieldCompareUnit]
|
|
single_source_fields: list[dict]
|
|
excluded_candidates: list[dict]
|
|
```
|
|
|
|
## 4. 核心方法
|
|
|
|
### 4.1 `run(input) -> FieldGroupOutput`
|
|
|
|
主入口方法。
|
|
|
|
### 4.2 `group_by_field_key(candidates) -> dict`
|
|
|
|
按字段编码分组。
|
|
|
|
### 4.3 `filter_candidates_by_scope(candidates, scope_documents) -> list`
|
|
|
|
只保留审核范围内来源文档的候选。
|
|
|
|
### 4.4 `build_compare_unit(field_key, candidates) -> FieldCompareUnit`
|
|
|
|
构建字段比对单元。
|
|
|
|
## 5. 技术实现
|
|
|
|
使用技术:
|
|
|
|
1. Python 分组
|
|
2. 字段池候选记录
|
|
3. 文档范围过滤
|
|
|
|
## 6. 异常处理
|
|
|
|
1. 字段无候选:进入待复核。
|
|
2. 来源文档不在范围内:排除候选。
|
|
3. 单来源字段:标记 `single_source`。
|
|
|
|
## 7. 测试要点
|
|
|
|
1. 候选按字段分组正确。
|
|
2. 范围外候选被排除。
|
|
3. 单来源字段识别正确。
|
|
|