层级多选
在 Potato 中搭建可展开的树形分类选择器,用于层级分类、主题打标和多层级类目标注任务。
层级多选标注方案提供一个可展开的树形界面,从嵌套的分类体系中选择类目。它适合标签本身按层级组织的任务,比如主题分类、商品归类,以及各类多层级打标。
Hierarchical multiselect in Potato
概览
层级多选方案呈现为一棵可折叠的树:
- 父节点展开后显示子类目
- 叶节点可以单独选中
- 可选的联动选择,把选中状态沿树向上或向下传递
- 搜索功能让标注者在大型分类体系中快速找到类目
快速开始
yaml
annotation_schemes:
- annotation_type: hierarchical_multiselect
name: topic_tags
description: Select all applicable topic categories.
taxonomy:
Science:
Physics:
- Quantum Mechanics
- Thermodynamics
Biology:
- Genetics
- Ecology
Technology:
- Software
- Hardware配置项
| 字段 | 类型 | 默认值 | 说明 |
|---|---|---|---|
annotation_type | string | 必填 | 必须为 "hierarchical_multiselect" |
name | string | 必填 | 本方案的唯一标识符 |
description | string | 必填 | 展示给标注者的说明文字 |
taxonomy | object | 必填 | 定义类目层级的嵌套对象 |
auto_select_children | boolean | false | 选中父节点时自动选中它的全部子节点 |
auto_select_parent | boolean | false | 全部子节点被选中时自动选中父节点 |
show_search | boolean | false | 是否显示搜索框来过滤分类树 |
max_selections | integer/null | null | 最多可选的类目数量(null 表示不限) |
expand_depth | integer | 1 | 默认展开的树层级数 |
label_requirement.required | boolean | false | 提交前是否至少要选一项 |
示例
主题分类
yaml
annotation_schemes:
- annotation_type: hierarchical_multiselect
name: topic_classification
description: Select all topics that apply to this document.
show_search: true
max_selections: 5
taxonomy:
Politics:
Domestic:
- Elections
- Legislation
- Policy
International:
- Diplomacy
- Trade
- Conflict
Sports:
- Football
- Basketball
- Tennis
Entertainment:
Film:
- Reviews
- Industry News
Music:
- Reviews
- Concerts带联动选择的商品归类
yaml
annotation_schemes:
- annotation_type: hierarchical_multiselect
name: product_category
description: Categorize this product listing.
auto_select_children: true
auto_select_parent: true
taxonomy:
Electronics:
Computers:
- Laptops
- Desktops
- Tablets
Audio:
- Headphones
- Speakers
Clothing:
Men:
- Shirts
- Pants
Women:
- Dresses
- Tops医学编码
yaml
annotation_schemes:
- annotation_type: hierarchical_multiselect
name: diagnosis_codes
description: Select all applicable diagnosis categories.
show_search: true
taxonomy:
Cardiovascular:
Hypertension:
- Primary
- Secondary
Arrhythmia:
- Atrial Fibrillation
- Ventricular Tachycardia
Respiratory:
Obstructive:
- Asthma
- COPD
Infectious:
- Pneumonia
- Bronchitis输出格式
json
{
"topic_tags": {
"labels": ["Science > Physics > Quantum Mechanics", "Technology > Software"]
}
}选中的类目以从根到叶的完整路径字符串保存。
实践建议
- 分类体系别做得太大 —— 嵌套不要超过 4 层,太深的树很难浏览
- 大型分类体系要开搜索 —— 类目超过 30 个时,
show_search: true对可用性的提升很明显 - 联动选择要谨慎用 —— 父类目确实涵盖所有子类目时它很方便,否则容易让人困惑
- 设置合适的展开深度 —— 展开的层数要够标注者看清结构,又不至于信息过载
- 需要时限制选择数量 —— 用
max_selections避免标注者打标过多
延伸阅读
有关实现详情,请参阅源文档。