文本
Text标签用于显示可标注的文本内容。该标签可在标注界面上展示任意类型的文本。
您可以使用来保留文本中的所有空格,否则在显示和保存结果时空格会被自动修剪。
在计算结果偏移量时(例如用于命名实体识别标注任务),文本样本中的每个空格都会被计入。
适用于以下数据类型:文本。
如何在Python中读取我的文本文件?
Label Studio编辑器将\r\n计为两个不同符号,显示为\n\n,导致行间看起来有额外间距。
您应该预处理文件将\r\n完全替换为\n,或者在Python中使用newline=''打开文件以避免将\r\n转换为\n:
with open('my-file.txt', encoding='utf-8', newline='') as f: text = f.read()
这在您进行跨度NER标注并需要获取正确偏移量时尤为重要:
text[start_offset:end_offset]
参数
| 参数 | 类型 | 默认值 | 描述 |
|---|---|---|---|
| name | string |
Name of the element | |
| value | string |
Data field containing text or a UR | |
| [valueType] | url | text |
text |
Whether the text is stored directly in uploaded data or needs to be loaded from a URL |
| [saveTextResult] | yes | no |
Whether to store labeled text along with the results. By default, doesn’t store text for valueType=url |
|
| [encoding] | none | base64 | base64unicode |
How to decode values from encoded strings | |
| [selectionEnabled] | boolean |
true |
Enable or disable selection |
| [highlightColor] | string |
Hex string with highlight color, if not provided uses the labels color | |
| [showLabels] | boolean |
Whether or not to show labels next to the region; unset (by default) — use editor settings; true/false — override settings | |
| [granularity] | symbol | word | sentence | paragraph |
Control region selection granularity |
结果参数
| 名称 | 类型 | 描述 |
|---|---|---|
| value | Object |
|
| value.start | string |
position of the start of the region in characters |
| value.end | string |
position of the end of the region in characters |
| [value.text] | string |
text content of the region, can be skipped |
示例JSON
{
"value": {
"start": 2,
"end": 81,
"labels": ["Car"]
}
}
示例
用于NER任务的文本标注配置,支持词级粒度
<View>
<Text name="text-1" value="$text" granularity="word" highlightColor="#ff0000" />
<Labels name="ner" toName="text-1">
<Label value="Person" />
<Label value="Location" />
</Labels>
</View>
示例
<Text name="p1">Some simple text with explanations</Text>