You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docs/source/tags/text.md
+7
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,13 @@ Every space in the text sample is counted when calculating result offsets, for e
12
12
13
13
Use with the following data types: text.
14
14
15
+
### How to read my text files in python?
16
+
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.
17
+
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`:
18
+
`with open('my-file.txt', encoding='utf-8', newline='') as f: text = f.read()`
19
+
This is especially important when you are doing span NER labeling and need to get the correct offsets:
Copy file name to clipboardexpand all lines: web/libs/editor/src/tags/object/Text.js
+8
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,14 @@
6
6
* Every space in the text sample is counted when calculating result offsets, for example for NER labeling tasks.
7
7
*
8
8
* Use with the following data types: text.
9
+
*
10
+
* ### How to read my text files in python?
11
+
* 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.
12
+
* 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`:
13
+
* `with open('my-file.txt', encoding='utf-8', newline='') as f: text = f.read()`
14
+
* This is especially important when you are doing span NER labeling and need to get the correct offsets:
15
+
* `text[start_offset:end_offset]`
16
+
*
9
17
* @example
10
18
* <!--Labeling configuration to label text for NER tasks with a word-level granularity -->
0 commit comments