Skip to content

Commit 3159c46

Browse files
authored
Merge pull request #857 from Labelbox/ovalle15-patch-7
Annotation Import Text - updates to ontology, tools, misc
2 parents fa8e81d + ce1187e commit 3159c46

File tree

1 file changed

+35
-63
lines changed

1 file changed

+35
-63
lines changed

examples/annotation_import/text.ipynb

Lines changed: 35 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -86,33 +86,19 @@
8686
},
8787
{
8888
"cell_type": "code",
89-
"execution_count": null,
89+
"execution_count": 36,
9090
"id": "4d63074b-2379-48af-b9d6-2a66190f03c4",
9191
"metadata": {
92-
"id": "4d63074b-2379-48af-b9d6-2a66190f03c4",
93-
"colab": {
94-
"base_uri": "https://localhost:8080/"
95-
},
96-
"outputId": "0b4547c9-e534-441d-9bf6-7588ee50c8a2"
92+
"id": "4d63074b-2379-48af-b9d6-2a66190f03c4"
9793
},
98-
"outputs": [
99-
{
100-
"output_type": "stream",
101-
"name": "stdout",
102-
"text": [
103-
"\u001b[K |████████████████████████████████| 184 kB 5.2 MB/s \n",
104-
"\u001b[K |████████████████████████████████| 7.8 MB 45.4 MB/s \n",
105-
"\u001b[?25h Building wheel for pygeotile (setup.py) ... \u001b[?25l\u001b[?25hdone\n"
106-
]
107-
}
108-
],
94+
"outputs": [],
10995
"source": [
11096
"!pip install -q 'labelbox[data]'"
11197
]
11298
},
11399
{
114100
"cell_type": "code",
115-
"execution_count": null,
101+
"execution_count": 37,
116102
"id": "01fca8c9-0680-4a9c-a11e-1b49f31e9121",
117103
"metadata": {
118104
"id": "01fca8c9-0680-4a9c-a11e-1b49f31e9121"
@@ -144,7 +130,7 @@
144130
},
145131
{
146132
"cell_type": "code",
147-
"execution_count": null,
133+
"execution_count": 38,
148134
"id": "86003724-4807-4281-95c1-5284a6f9609f",
149135
"metadata": {
150136
"id": "86003724-4807-4281-95c1-5284a6f9609f"
@@ -199,7 +185,7 @@
199185
"id": "Z5ORHD1pZKt1"
200186
},
201187
"id": "Z5ORHD1pZKt1",
202-
"execution_count": null,
188+
"execution_count": 39,
203189
"outputs": []
204190
},
205191
{
@@ -226,26 +212,13 @@
226212
"id": "mrPJ1Ko0ZMdl"
227213
},
228214
"id": "mrPJ1Ko0ZMdl",
229-
"execution_count": null,
215+
"execution_count": 40,
230216
"outputs": []
231217
},
232218
{
233219
"cell_type": "code",
234220
"source": [
235-
"########## Classification - Radio (with subclassifcations) ##########\n",
236-
"\n",
237-
"# Python annotation\n",
238-
"radio_annotation_nested = ClassificationAnnotation(\n",
239-
" name=\"radio_question_sub\", \n",
240-
" value=Radio(answer = ClassificationAnswer(name = \"first_radio_answer\")),\n",
241-
" classifications=[\n",
242-
" \tClassificationAnnotation(\n",
243-
" \tname=\"sub_radio_question\",\n",
244-
" \t\tvalue=Radio(answer=ClassificationAnswer(name=\"first_sub_radio_answer\"))\n",
245-
" )\n",
246-
" ]\n",
247-
")\n",
248-
"\n",
221+
"########## Classification - Radio (with subclassifcations) is only suppported with NDJSON tools ##########\n",
249222
"\n",
250223
"# NDJSON\n",
251224
"radio_annotation_ndjson_with_subclass = {\n",
@@ -263,7 +236,7 @@
263236
"id": "vt7QvfV7ZPAF"
264237
},
265238
"id": "vt7QvfV7ZPAF",
266-
"execution_count": null,
239+
"execution_count": 41,
267240
"outputs": []
268241
},
269242
{
@@ -296,12 +269,12 @@
296269
"id": "45BDh768ZYsH"
297270
},
298271
"id": "45BDh768ZYsH",
299-
"execution_count": null,
272+
"execution_count": 42,
300273
"outputs": []
301274
},
302275
{
303276
"cell_type": "code",
304-
"execution_count": null,
277+
"execution_count": 43,
305278
"id": "f9f9287c-aad7-4914-bc87-1453fb8bce81",
306279
"metadata": {
307280
"id": "f9f9287c-aad7-4914-bc87-1453fb8bce81"
@@ -364,27 +337,27 @@
364337
"base_uri": "https://localhost:8080/"
365338
},
366339
"id": "Ak-jnABK3OPH",
367-
"outputId": "ff481cce-af08-4748-e8ac-a959085e07de"
340+
"outputId": "0f80ba52-adde-4d97-d04a-fcdbe4d1a414"
368341
},
369342
"id": "Ak-jnABK3OPH",
370-
"execution_count": null,
343+
"execution_count": 44,
371344
"outputs": [
372345
{
373346
"output_type": "stream",
374347
"name": "stdout",
375348
"text": [
376349
"<DataRow {\n",
377-
" \"created_at\": \"2022-12-22 20:59:28+00:00\",\n",
350+
" \"created_at\": \"2023-01-30 18:06:23+00:00\",\n",
378351
" \"external_id\": null,\n",
379-
" \"global_key\": \"TEST-ID-190217471490724126308456269288159181446d\",\n",
352+
" \"global_key\": \"TEST-ID-321668750509639104503407808903937477958d\",\n",
380353
" \"media_attributes\": {},\n",
381354
" \"metadata\": [],\n",
382355
" \"metadata_fields\": [],\n",
383356
" \"row_data\": \"https://storage.googleapis.com/labelbox-sample-datasets/nlp/lorem-ipsum.txt\",\n",
384-
" \"uid\": \"clbzkhbxy18ws07ysdumbbgnq\",\n",
385-
" \"updated_at\": \"2022-12-22 20:59:28+00:00\"\n",
357+
" \"uid\": \"cldj4gyf60fy207xh3z1y2g1h\",\n",
358+
" \"updated_at\": \"2023-01-30 18:06:23+00:00\"\n",
386359
"}>\n",
387-
"clbzkhbxy18ws07ysdumbbgnq\n"
360+
"cldj4gyf60fy207xh3z1y2g1h\n"
388361
]
389362
}
390363
]
@@ -395,7 +368,7 @@
395368
"### Step 2: Create/select an ontology\n",
396369
"Your project should have the correct ontology setup with all the tools and classifications supported for your annotations, and the tool names and classification instructions should match the `name`/`instructions` fields in your annotations to ensure the correct feature schemas are matched.\n",
397370
"\n",
398-
"For example, when we create the checklist annotation [above](https://colab.research.google.com/drive/1mXfgydXxVR2OMAjJo1nj2EU9QQyVhW90#scrollTo=45BDh768ZYsH&line=1&uniqifier=1), we provided the `name` as `checklist_question`. Now, when we setup our ontology, we must ensure that the name of my classification tool is also `checklist_question`. The same alignment must hold true for the other tools and classifications we create in our ontology.\n",
371+
"For example, when we create the checklist annotation above, we provided the `name` as `checklist_question`. Now, when we setup our ontology, we must ensure that the name of my classification tool is also `checklist_question`. The same alignment must hold true for the other tools and classifications we create in our ontology.\n",
399372
"\n",
400373
"[Documentation for reference ](https://docs.labelbox.com/reference/import-text-annotations)"
401374
],
@@ -459,7 +432,7 @@
459432
"id": "_wWxYFoDTsar"
460433
},
461434
"id": "_wWxYFoDTsar",
462-
"execution_count": null,
435+
"execution_count": 45,
463436
"outputs": []
464437
},
465438
{
@@ -475,7 +448,7 @@
475448
},
476449
{
477450
"cell_type": "code",
478-
"execution_count": null,
451+
"execution_count": 46,
479452
"id": "044e9194-d21d-403e-b64c-047c1063b0fe",
480453
"metadata": {
481454
"id": "044e9194-d21d-403e-b64c-047c1063b0fe"
@@ -537,22 +510,22 @@
537510
"colab": {
538511
"base_uri": "https://localhost:8080/"
539512
},
540-
"outputId": "153857ae-455d-4c7c-fb36-40fc16dc0819"
513+
"outputId": "6eb66aad-477d-490e-ea91-53de995f1f65"
541514
},
542515
"id": "DbwheC8RzI-0",
543-
"execution_count": null,
516+
"execution_count": 47,
544517
"outputs": [
545518
{
546519
"output_type": "stream",
547520
"name": "stdout",
548521
"text": [
549522
"Batch: <Batch {\n",
550523
" \"consensus_settings_json\": \"{\\\"numberOfLabels\\\":1,\\\"coveragePercentage\\\":0}\",\n",
551-
" \"created_at\": \"2022-12-22 20:59:51+00:00\",\n",
524+
" \"created_at\": \"2023-01-30 18:06:28+00:00\",\n",
552525
" \"name\": \"first-batch-text-demo\",\n",
553526
" \"size\": 1,\n",
554-
" \"uid\": \"94297660-823b-11ed-8039-c1b641c04d88\",\n",
555-
" \"updated_at\": \"2022-12-22 20:59:51+00:00\"\n",
527+
" \"uid\": \"d14be9f0-a0c8-11ed-a7e5-f9da6146996d\",\n",
528+
" \"updated_at\": \"2023-01-30 18:06:28+00:00\"\n",
556529
"}>\n"
557530
]
558531
}
@@ -575,7 +548,7 @@
575548
{
576549
"cell_type": "markdown",
577550
"source": [
578-
"#### Python Annotations"
551+
"#### Python annotations"
579552
],
580553
"metadata": {
581554
"id": "7IgSl5SxcO4R"
@@ -584,7 +557,7 @@
584557
},
585558
{
586559
"cell_type": "code",
587-
"execution_count": null,
560+
"execution_count": 48,
588561
"id": "53aaf87b-114f-4b56-a417-8c7cddc1f532",
589562
"metadata": {
590563
"id": "53aaf87b-114f-4b56-a417-8c7cddc1f532"
@@ -599,8 +572,7 @@
599572
" named_entitity_annotation, \n",
600573
" radio_annotation, \n",
601574
" checklist_annotation, \n",
602-
" text_annotation, \n",
603-
" radio_annotation_nested \n",
575+
" text_annotation\n",
604576
" ]\n",
605577
")\n",
606578
"\n",
@@ -628,7 +600,7 @@
628600
},
629601
{
630602
"cell_type": "code",
631-
"execution_count": null,
603+
"execution_count": 49,
632604
"id": "c66672c7-33e8-4d5d-b79d-2ac76d830341",
633605
"metadata": {
634606
"id": "c66672c7-33e8-4d5d-b79d-2ac76d830341"
@@ -693,10 +665,10 @@
693665
"base_uri": "https://localhost:8080/"
694666
},
695667
"id": "izli4zhEfi75",
696-
"outputId": "b1cdc2d0-9541-4df2-d922-be0a7ce80499"
668+
"outputId": "4eb1b790-4e60-4cc6-9224-de6a9ed339bf"
697669
},
698670
"id": "izli4zhEfi75",
699-
"execution_count": null,
671+
"execution_count": 50,
700672
"outputs": [
701673
{
702674
"output_type": "stream",
@@ -720,14 +692,14 @@
720692
},
721693
{
722694
"cell_type": "code",
723-
"execution_count": null,
695+
"execution_count": 51,
724696
"id": "e8d4e99b-ad7e-48b9-8073-afb764d7c5b4",
725697
"metadata": {
726698
"id": "e8d4e99b-ad7e-48b9-8073-afb764d7c5b4",
727699
"colab": {
728700
"base_uri": "https://localhost:8080/"
729701
},
730-
"outputId": "be9df775-f18c-44ed-e02e-82b3c2a3691f"
702+
"outputId": "1e52b23b-cefc-439b-f374-2e8b886280f4"
731703
},
732704
"outputs": [
733705
{
@@ -770,7 +742,7 @@
770742
"id": "ubbraAmo2_fe"
771743
},
772744
"id": "ubbraAmo2_fe",
773-
"execution_count": null,
745+
"execution_count": 52,
774746
"outputs": []
775747
}
776748
],

0 commit comments

Comments
 (0)