Skip to main content

<Text>

Category: Object tag

The Text tag shows text that can be labeled. Use to display any type of text on the labeling interface. You can use <Style>.htx-text{ white-space: pre-wrap; }</Style> to preserve all spaces in the text, otherwise spaces are trimmed when displayed and saved in the results. Every space in the text sample is counted when calculating result offsets, for example for NER labeling tasks.

Use with the following data types: text.

How to read my text files in python?​

The Label Studio editor counts \r\n as two different symbols, displaying them as \n\n, making it look like there is extra margin between lines. You should either preprocess your files to replace \r\n with \n completely, or open files in Python with newline='' to avoid converting \r\n to \n: with open('my-file.txt', encoding='utf-8', newline='') as f: text = f.read() This is especially important when you are doing span NER labeling and need to get the correct offsets: text[start_offset:end_offset]

Attributes​

AttributeTypeRequiredDefaultDescription
namestringyes—Name of the element
valuestringyes—Data field containing text or a UR
valueTypeurl,textnotextWhether the text is stored directly in uploaded data or needs to be loaded from a URL
saveTextResultyes,nono—Whether to store labeled text along with the results. By default, doesn't store text for valueType=url
encodingnone,base64,base64unicodeno—How to decode values from encoded strings
selectionEnabledtrue,falsenotrueEnable or disable selection
highlightColorstringno—Hex string with highlight color, if not provided uses the labels color
showLabelstrue,falseno—Whether or not to show labels next to the region; unset (by default) — use editor settings; true/false — override settings
granularitysymbol,word,sentence,paragraphno—Control region selection granularity
dirltr,rtl,autono—Text direction for RTL / non-Latin script rendering. rtl renders Arabic-script content right-to-left with correct bidi. <Text dir="rtl" lang="ar"> reaches the DOM as a dir="rtl" container so the browser handles bidirectional text natively. AfriAnnotate-specific.
directionltr,rtl,autono—CSS-familiar alias of dir. dir wins on collision. AfriAnnotate-specific.
langstring (BCP 47)no—Language tag such as ar (Arabic), am (Amharic), ha-Arab (Hausa Ajami), ff-Arab (Fulfulde Ajami), kr-Arab (Kanuri Ajami), or zgh-Tfng (Standard Moroccan Tamazight in Tifinagh). When set together with granularity="word" or granularity="sentence", selection snapping runs through Intl.Segmenter(lang) — ICU-backed word / sentence boundaries respecting the specific locale rather than whatever the browser's default happens to be. Falls back to the browser Selection.modify path on missing lang, unsupported browsers, paragraph granularity, or multi-container selections. AfriAnnotate-specific.
unicodeBidinormal,embed,bidi-override,isolate,isolate-override,plaintextno—CSS unicode-bidi behaviour, mapped onto the rendered container's style. Combine with dir for stubborn mixed-script rendering (e.g. Arabic quotations inside English body). AfriAnnotate-specific.

For the end-to-end walkthrough with six ready-made African-language template presets, see the RTL and non-Latin scripts guide.

Examples​

Labeling configuration to label text for NER tasks with a word-level granularity​

<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>

Example 2​

<Text name="p1">Some simple text with explanations</Text>