Spaces:
Runtime error
Runtime error
Create text_annotatator.py
Browse files- text_annotatator.py +49 -0
text_annotatator.py
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
def get_display_only_data():
|
2 |
+
data1 = {
|
3 |
+
"tokens": [
|
4 |
+
{"text": "He", "labels": ["Person"]},
|
5 |
+
{"text": "loves"},
|
6 |
+
{"text": "his"},
|
7 |
+
{"text": "dog", "labels": ["Animal", "Pet"]},
|
8 |
+
],
|
9 |
+
"labels": [
|
10 |
+
{"text": "Person"},
|
11 |
+
{"text": "Action"},
|
12 |
+
{"text": "Animal"},
|
13 |
+
]
|
14 |
+
}
|
15 |
+
return data1
|
16 |
+
|
17 |
+
def get_editable_data():
|
18 |
+
|
19 |
+
data2 = {
|
20 |
+
"allowEditing": True,
|
21 |
+
"tokens": [
|
22 |
+
{"text": "He", "labels": ["Pronoun", "Person"]},
|
23 |
+
{"text": "loves", "labels": ["Action"]},
|
24 |
+
{"text": "his"},
|
25 |
+
{"text": "dog", "labels": ["Animal"]},
|
26 |
+
],
|
27 |
+
"labels": [
|
28 |
+
{"text": "Pronoun", "style": {
|
29 |
+
"color": "red",
|
30 |
+
"background-color": "white",
|
31 |
+
"font-size": "8px",
|
32 |
+
"border": "3px dashed red",
|
33 |
+
}},
|
34 |
+
{"text": "Verb", "style": {
|
35 |
+
"color": "green",
|
36 |
+
"background-color": "white",
|
37 |
+
"font-size": "8px",
|
38 |
+
"font-weight": "900",
|
39 |
+
}},
|
40 |
+
{"text": "Noun", "style": {
|
41 |
+
"color": "blue",
|
42 |
+
"background-color": "white",
|
43 |
+
"font-size": "8px",
|
44 |
+
}},
|
45 |
+
{"text": "Person"},
|
46 |
+
{"text": "Animal"},
|
47 |
+
]
|
48 |
+
}
|
49 |
+
return data 2
|