Skip to content

Commit 4cf3e55

Browse files
ovalle15ovalle15ezekielemerson
authored
[ SN-48, SN-47 ] : Adding new notebooks + small updates (#1067)
Co-authored-by: ovalle15 <aovalle@Andreas-MacBook-Pro-2.local> Co-authored-by: Zeke <91079021+ezekielemerson@users.noreply.github.com>
1 parent e26f972 commit 4cf3e55

File tree

5 files changed

+2123
-16
lines changed

5 files changed

+2123
-16
lines changed

examples/annotation_import/conversational.ipynb

Lines changed: 114 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"* Classification Checklist \n",
4040
"* Classification Free Text \n",
4141
"* NER\n",
42+
"* Relationships (only supported for MAL imports)\n",
4243
"\n",
4344
"**Not** supported annotations\n",
4445
"\n",
@@ -125,13 +126,6 @@
125126
],
126127
"cell_type": "markdown"
127128
},
128-
{
129-
"metadata": {},
130-
"source": [
131-
"### NDJSON Annotations "
132-
],
133-
"cell_type": "markdown"
134-
},
135129
{
136130
"metadata": {},
137131
"source": [
@@ -302,6 +296,83 @@
302296
"outputs": [],
303297
"execution_count": null
304298
},
299+
{
300+
"metadata": {},
301+
"source": [
302+
"# ############ global nested classifications ###########\n",
303+
"# Message based\n",
304+
"nested_checklist_annotation = lb_types.ClassificationAnnotation(\n",
305+
" name=\"nested_checklist_question\",\n",
306+
" message_id=\"10\",\n",
307+
" value=lb_types.Checklist(\n",
308+
" answer=[lb_types.ClassificationAnswer(\n",
309+
" name=\"first_checklist_answer\",\n",
310+
" classifications=[\n",
311+
" lb_types.ClassificationAnnotation(\n",
312+
" name=\"sub_checklist_question\",\n",
313+
" value=lb_types.Checklist(\n",
314+
" answer=[lb_types.ClassificationAnswer(\n",
315+
" name=\"first_sub_checklist_answer\",\n",
316+
"\n",
317+
" )]\n",
318+
" ))\n",
319+
" ]\n",
320+
" )]\n",
321+
" )\n",
322+
")\n",
323+
"# Message based\n",
324+
"nested_checklist_annotation_ndjson = {\n",
325+
" \"name\": \"nested_checklist_question\",\n",
326+
" \"messageId\": \"10\",\n",
327+
" \"answer\": [{\n",
328+
" \"name\": \"first_checklist_answer\",\n",
329+
" \"classifications\" : [\n",
330+
" {\n",
331+
" \"name\": \"sub_checklist_question\", \n",
332+
" \"answer\": {\n",
333+
" \"name\": \"first_sub_checklist_answer\"\n",
334+
" }\n",
335+
" } \n",
336+
" ] \n",
337+
" }]\n",
338+
"}\n",
339+
"# Global\n",
340+
"nested_radio_annotation = lb_types.ClassificationAnnotation(\n",
341+
" name=\"nested_radio_question\",\n",
342+
" value=lb_types.Radio(\n",
343+
" answer=lb_types.ClassificationAnswer(\n",
344+
" name=\"first_radio_answer\",\n",
345+
" classifications=[\n",
346+
" lb_types.ClassificationAnnotation(\n",
347+
" name=\"sub_radio_question\",\n",
348+
" value=lb_types.Radio(\n",
349+
" answer=lb_types.ClassificationAnswer(\n",
350+
" name=\"first_sub_radio_answer\"\n",
351+
" )\n",
352+
" )\n",
353+
" )\n",
354+
" ]\n",
355+
" )\n",
356+
" )\n",
357+
")\n",
358+
"\n",
359+
"# Global\n",
360+
"nested_radio_annotation_ndjson = {\n",
361+
" \"name\": \"nested_radio_question\",\n",
362+
" \"answer\": {\n",
363+
" \"name\": \"first_radio_answer\",\n",
364+
" \"classifications\": [{\n",
365+
" \"name\":\"sub_radio_question\",\n",
366+
" \"answer\": { \"name\" : \"first_sub_radio_answer\"}\n",
367+
" }]\n",
368+
" }\n",
369+
"}\n",
370+
"\n"
371+
],
372+
"cell_type": "code",
373+
"outputs": [],
374+
"execution_count": null
375+
},
305376
{
306377
"metadata": {},
307378
"source": [
@@ -379,6 +450,36 @@
379450
" lb.Option(value=\"first_radio_answer\"),\n",
380451
" lb.Option(value=\"second_radio_answer\")\n",
381452
" ]\n",
453+
" ),\n",
454+
" lb.Classification(\n",
455+
" class_type=lb.Classification.Type.CHECKLIST,\n",
456+
" name=\"nested_checklist_question\",\n",
457+
" scope = lb.Classification.Scope.INDEX,\n",
458+
" options=[\n",
459+
" lb.Option(\"first_checklist_answer\",\n",
460+
" options=[\n",
461+
" lb.Classification(\n",
462+
" class_type=lb.Classification.Type.CHECKLIST,\n",
463+
" name=\"sub_checklist_question\", \n",
464+
" options=[lb.Option(\"first_sub_checklist_answer\")]\n",
465+
" )\n",
466+
" ])\n",
467+
" ]\n",
468+
" ),\n",
469+
" lb.Classification(\n",
470+
" class_type=lb.Classification.Type.RADIO,\n",
471+
" name=\"nested_radio_question\",\n",
472+
" scope = lb.Classification.Scope.GLOBAL,\n",
473+
" options=[\n",
474+
" lb.Option(\"first_radio_answer\",\n",
475+
" options=[\n",
476+
" lb.Classification(\n",
477+
" class_type=lb.Classification.Type.RADIO,\n",
478+
" name=\"sub_radio_question\",\n",
479+
" options=[lb.Option(\"first_sub_radio_answer\")]\n",
480+
" )\n",
481+
" ])\n",
482+
" ]\n",
382483
" )\n",
383484
" ]\n",
384485
")\n",
@@ -402,7 +503,7 @@
402503
"metadata": {},
403504
"source": [
404505
"# Create Labelbox project\n",
405-
"project = client.create_project(name=\"conversational_project\", \n",
506+
"project = client.create_project(name=\"Conversational Text Annotation Import Demo\", \n",
406507
" media_type=lb.MediaType.Conversational)\n",
407508
"\n",
408509
"# Setup your ontology \n",
@@ -471,7 +572,9 @@
471572
" radio_annotation,\n",
472573
" ner_source,\n",
473574
" ner_target,\n",
474-
" ner_relationship\n",
575+
" ner_relationship,\n",
576+
" nested_radio_annotation,\n",
577+
" nested_checklist_annotation\n",
475578
" ]\n",
476579
" )\n",
477580
")"
@@ -500,6 +603,8 @@
500603
" ner_source_ndjson,\n",
501604
" ner_target_ndjson,\n",
502605
" ner_relationship_annotation_ndjson,\n",
606+
" nested_checklist_annotation_ndjson,\n",
607+
" nested_radio_annotation_ndjson\n",
503608
" ]:\n",
504609
" annotations.update({\n",
505610
" \"dataRow\": {\n",

0 commit comments

Comments
 (0)