选项
Choices标签用于创建一组选项,包含单选按钮或复选框。它可用于单类别或多类别分类任务。此外,该标签也适用于高级分类场景,标注者可以选择一个或多个答案。
选项可以具有动态值以从任务加载标签。此任务数据应包含一个选项列表,用于创建底层的。所有来自选项的参数都将传递到相应的标签。
Choices标签可用于任何数据类型。
参数
| 参数 | 类型 | 默认值 | 描述 |
|---|---|---|---|
| name | string |
Name of the group of choices | |
| toName | string |
Name of the data item that you want to label | |
| [choice] | single | single-radio | multiple |
single |
Single or multi-class classification |
| [showInline] | boolean |
false |
Show choices in the same visual line |
| [required] | boolean |
false |
Validate whether a choice has been selected |
| [requiredMessage] | string |
Show a message if validation fails | |
| [visibleWhen] | region-selected | no-region-selected | choice-selected | choice-unselected |
Control visibility of the choices. Can also be used with the when* parameters below to narrow down visibility |
|
| [whenTagName] | string |
Use with visibleWhen. Narrow down visibility by name of the tag. For regions, use the name of the object tag, for choices, use the name of the choices tag |
|
| [whenLabelValue] | string |
Use with visibleWhen="region-selected". Narrow down visibility by label value. Multiple values can be separated with commas |
|
| [whenChoiceValue] | string |
Use with visibleWhen ("choice-selected" or "choice-unselected") and whenTagName, both are required. Narrow down visibility by choice value. Multiple values can be separated with commas |
|
| [perRegion] | boolean |
Use this tag to select a choice for a specific region instead of the entire task | |
| [perItem] | boolean |
Use this tag to select a choice for a specific item inside the object instead of the whole object | |
| [value] | string |
Task data field containing a list of dynamically loaded choices (see example below) | |
| [allowNested] | boolean |
Allow to use children field in dynamic choices to nest them. Submitted result will contain array of arrays, every item is a list of values from topmost parent choice down to selected one. |
示例
基础文本分类标注配置
<View>
<Choices name="gender" toName="txt-1" choice="single-radio">
<Choice alias="M" value="Male" />
<Choice alias="F" value="Female" />
<Choice alias="NB" value="Nonbinary" />
<Choice alias="X" value="Other" />
</Choices>
<Text name="txt-1" value="John went to see Mary" />
</View>
示例 (此配置使用动态标签)
Choices can be loaded dynamically from task data. It should be an array of objects with attributes.
html can be used to show enriched content, it has higher priority than value, however value will be used in the exported result.
<View>
<Audio name="audio" value="$audio" />
<Choices name="transcription" toName="audio" value="$variants" />
</View>
<!-- {
"data": {
"variants": [
{ "value": "Do or doughnut. There is no try.", "html": "<img src='https://labelstud.io/images/logo.png'>" },
{ "value": "Do or do not. There is no trial.", "html": "<h1>You can use hypertext here</h2>" },
{ "value": "Do or do not. There is no try." },
{ "value": "Duo do not. There is no try." }
]
}
} -->
示例 (等同于以下配置)
<View>
<Audio name="audio" value="$audio" />
<Choices name="transcription" toName="audio" value="$variants">
<Choice value="Do or doughnut. There is no try." />
<Choice value="Do or do not. There is no trial." />
<Choice value="Do or do not. There is no try." />
<Choice value="Duo do not. There is no try." />
</Choices>
</View>