Skip to content

Commit eb04f7c

Browse files
authored
[SN-82] Remove relationship annotations from text and conversational … (#1315)
1 parent 155d347 commit eb04f7c

File tree

2 files changed

+23
-174
lines changed

2 files changed

+23
-174
lines changed

examples/annotation_import/conversational.ipynb

Lines changed: 11 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,17 @@
3333
"# Conversational Text Annotation Import\n",
3434
"* This notebook will provide examples of each supported annotation type for conversational text assets, and also cover MAL and Label Import methods:\n",
3535
"\n",
36-
"Suported annotations that can be uploaded through the SDK\n",
36+
"Supported annotations that can be uploaded through the SDK\n",
3737
"\n",
3838
"* Classification Radio \n",
3939
"* Classification Checklist \n",
4040
"* Classification Free Text \n",
4141
"* NER\n",
42-
"* Relationships (only supported for MAL imports)\n",
42+
"\n",
4343
"\n",
4444
"**Not** supported annotations\n",
4545
"\n",
46+
"* Relationships\n",
4647
"* Bouding box \n",
4748
"* Polygon \n",
4849
"* Point\n",
@@ -231,71 +232,6 @@
231232
"outputs": [],
232233
"execution_count": null
233234
},
234-
{
235-
"metadata": {},
236-
"source": [
237-
"####### Relationships ########## \n",
238-
"ner_source = lb_types.ObjectAnnotation(\n",
239-
" name=\"ner\",\n",
240-
" value=lb_types.ConversationEntity(\n",
241-
" start=16,\n",
242-
" end=26,\n",
243-
" message_id=\"4\"\n",
244-
" )\n",
245-
")\n",
246-
"ner_target = lb_types.ObjectAnnotation(\n",
247-
" name=\"ner\",\n",
248-
" value=lb_types.ConversationEntity(\n",
249-
" start=29, \n",
250-
" end=34, \n",
251-
" message_id=\"4\"\n",
252-
" )\n",
253-
")\n",
254-
"\n",
255-
"ner_relationship = lb_types.RelationshipAnnotation(\n",
256-
" name=\"relationship\",\n",
257-
" value=lb_types.Relationship(\n",
258-
" source=ner_source,\n",
259-
" target=ner_target,\n",
260-
" type=lb_types.Relationship.Type.UNIDIRECTIONAL,\n",
261-
" ))\n",
262-
"\n",
263-
"uuid_source = str(uuid.uuid4())\n",
264-
"uuid_target = str(uuid.uuid4())\n",
265-
"\n",
266-
"ner_source_ndjson = { \n",
267-
" \"uuid\": uuid_source, \n",
268-
" \"name\": \"ner\",\n",
269-
" \"location\": { \n",
270-
" \"start\": 16, \n",
271-
" \"end\": 26 \n",
272-
" },\n",
273-
" \"messageId\": \"4\"\n",
274-
" }\n",
275-
"\n",
276-
"ner_target_ndjson = { \n",
277-
" \"uuid\": uuid_target,\n",
278-
" \"name\": \"ner\",\n",
279-
" \"location\": { \n",
280-
" \"start\": 29, \n",
281-
" \"end\": 34\n",
282-
" },\n",
283-
" \"messageId\": \"4\"\n",
284-
" }\n",
285-
"\n",
286-
"ner_relationship_annotation_ndjson = {\n",
287-
" \"name\": \"relationship\", \n",
288-
" \"relationship\": {\n",
289-
" \"source\": uuid_source,\n",
290-
" \"target\": uuid_target,\n",
291-
" \"type\": \"bidirectional\"\n",
292-
" }\n",
293-
"}"
294-
],
295-
"cell_type": "code",
296-
"outputs": [],
297-
"execution_count": null
298-
},
299235
{
300236
"metadata": {},
301237
"source": [
@@ -426,7 +362,6 @@
426362
"ontology_builder = lb.OntologyBuilder(\n",
427363
" tools=[ \n",
428364
" lb.Tool(tool=lb.Tool.Type.NER,name=\"ner\"),\n",
429-
" lb.Tool(tool=lb.Tool.Type.RELATIONSHIP,name=\"relationship\")\n",
430365
" ], \n",
431366
" classifications=[ \n",
432367
" lb.Classification( \n",
@@ -570,9 +505,6 @@
570505
" text_annotation,\n",
571506
" checklist_annotation,\n",
572507
" radio_annotation,\n",
573-
" ner_source,\n",
574-
" ner_target,\n",
575-
" ner_relationship,\n",
576508
" nested_radio_annotation,\n",
577509
" nested_checklist_annotation\n",
578510
" ]\n",
@@ -600,9 +532,6 @@
600532
" text_annotation_ndjson,\n",
601533
" checklist_annotation_ndjson,\n",
602534
" radio_annotation_ndjson,\n",
603-
" ner_source_ndjson,\n",
604-
" ner_target_ndjson,\n",
605-
" ner_relationship_annotation_ndjson,\n",
606535
" nested_checklist_annotation_ndjson,\n",
607536
" nested_radio_annotation_ndjson\n",
608537
" ]:\n",
@@ -661,19 +590,15 @@
661590
"metadata": {},
662591
"source": [
663592
"# Upload label for this data row in project \n",
664-
"# Uncomment this code when excluding relationships from label import\n",
665-
"# Relationships are not currently supported for label import\n",
593+
"upload_job = lb.LabelImport.create_from_objects(\n",
594+
" client = client, \n",
595+
" project_id = project.uid, \n",
596+
" name=\"label_import_job\"+str(uuid.uuid4()), \n",
597+
" labels=label)\n",
666598
"\n",
667-
"\n",
668-
"# upload_job = lb.LabelImport.create_from_objects(\n",
669-
"# client = client, \n",
670-
"# project_id = project.uid, \n",
671-
"# name=\"label_import_job\"+str(uuid.uuid4()), \n",
672-
"# labels=label)\n",
673-
"\n",
674-
"# upload_job.wait_until_done();\n",
675-
"# print(\"Errors:\", upload_job.errors)\n",
676-
"# print(\"Status of uploads: \", upload_job.statuses)"
599+
"upload_job.wait_until_done()\n",
600+
"print(\"Errors:\", upload_job.errors)\n",
601+
"print(\"Status of uploads: \", upload_job.statuses)"
677602
],
678603
"cell_type": "code",
679604
"outputs": [],

examples/annotation_import/text.ipynb

Lines changed: 12 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,10 @@
3939
"* Classification radio \n",
4040
"* Classification checklist \n",
4141
"* Classification free-form text \n",
42-
"* Relationships (Only supported for MAL and through the SDK)\n",
42+
"\n",
4343
"\n",
4444
"**Not** supported:\n",
45+
"* Relationships\n",
4546
"* Segmentation mask\n",
4647
"* Polygon\n",
4748
"* Bounding box \n",
@@ -294,70 +295,6 @@
294295
"outputs": [],
295296
"execution_count": null
296297
},
297-
{
298-
"metadata": {},
299-
"source": [
300-
"##### Relationship ##### \n",
301-
"# only supported for MAL imports \n",
302-
"ner_source = lb_types.ObjectAnnotation(\n",
303-
" name=\"named_entity\",\n",
304-
" value=lb_types.TextEntity(\n",
305-
" start=133, \n",
306-
" end=140\n",
307-
" )\n",
308-
")\n",
309-
"\n",
310-
"ner_target = lb_types.ObjectAnnotation(\n",
311-
" name=\"named_entity\",\n",
312-
" value=lb_types.TextEntity(\n",
313-
" start=143,\n",
314-
" end=159\n",
315-
" )\n",
316-
")\n",
317-
"\n",
318-
"ner_relationship = lb_types.RelationshipAnnotation(\n",
319-
" name=\"relationship\",\n",
320-
" value=lb_types.Relationship(\n",
321-
" source=ner_source,\n",
322-
" target=ner_target,\n",
323-
" type=lb_types.Relationship.Type.UNIDIRECTIONAL,\n",
324-
" ))\n",
325-
"\n",
326-
"\n",
327-
"uuid_source = str(uuid.uuid4())\n",
328-
"uuid_target = str(uuid.uuid4())\n",
329-
"\n",
330-
"entity_source_ndjson = {\n",
331-
" \"name\": \"named_entity\",\n",
332-
" \"uuid\": uuid_source,\n",
333-
" \"location\": {\n",
334-
" \"start\" : 133,\n",
335-
" \"end\": 140 \n",
336-
" }\n",
337-
"}\n",
338-
"\n",
339-
"entity_target_ndjson = {\n",
340-
" \"name\": \"named_entity\",\n",
341-
" \"uuid\": uuid_target,\n",
342-
" \"location\": {\n",
343-
" \"start\": 143,\n",
344-
" \"end\": 159\n",
345-
" }\n",
346-
"}\n",
347-
"\n",
348-
"ner_relationship_annotation_ndjson = {\n",
349-
" \"name\": \"relationship\", \n",
350-
" \"relationship\": {\n",
351-
" \"source\": uuid_source,\n",
352-
" \"target\": uuid_target,\n",
353-
" \"type\": \"unidirectional\"\n",
354-
" }\n",
355-
"}"
356-
],
357-
"cell_type": "code",
358-
"outputs": [],
359-
"execution_count": null
360-
},
361298
{
362299
"metadata": {},
363300
"source": [
@@ -472,10 +409,6 @@
472409
" tool=lb.Tool.Type.NER, \n",
473410
" name=\"named_entity\"\n",
474411
" ),\n",
475-
" lb.Tool( \n",
476-
" tool=lb.Tool.Type.RELATIONSHIP,\n",
477-
" name=\"relationship\"\n",
478-
" )\n",
479412
" ]\n",
480413
")\n",
481414
"\n",
@@ -566,9 +499,6 @@
566499
" radio_annotation, \n",
567500
" checklist_annotation, \n",
568501
" text_annotation,\n",
569-
" ner_source,\n",
570-
" ner_target,\n",
571-
" ner_relationship,\n",
572502
" nested_checklist_annotation,\n",
573503
" nested_radio_annotation\n",
574504
" ]\n",
@@ -596,9 +526,6 @@
596526
" text_annotation_ndjson,\n",
597527
" nested_radio_annotation_ndjson,\n",
598528
" nested_checklist_annotation_ndjson,\n",
599-
" entity_source_ndjson,\n",
600-
" entity_target_ndjson,\n",
601-
" ner_relationship_annotation_ndjson,\n",
602529
" ] :\n",
603530
" annotations.update({\n",
604531
" \"dataRow\": { \"globalKey\": global_key }\n",
@@ -636,7 +563,7 @@
636563
" name=\"mal_import_job\"+str(uuid.uuid4()), \n",
637564
" predictions=labels)\n",
638565
"\n",
639-
"upload_job_mal.wait_until_done();\n",
566+
"upload_job_mal.wait_until_done()\n",
640567
"print(\"Errors:\", upload_job_mal.errors)\n",
641568
"print(\"Status of uploads: \", upload_job_mal.statuses)"
642569
],
@@ -654,19 +581,16 @@
654581
{
655582
"metadata": {},
656583
"source": [
657-
"# Uncomment if relationships are not being imported. \n",
658-
"# Relationships will be supported for label import in the near future. \n",
659-
"\n",
660-
"# # Upload label for this data row in project \n",
661-
"# upload_job_label_import = lb.LabelImport.create_from_objects(\n",
662-
"# client = client, \n",
663-
"# project_id = project.uid, \n",
664-
"# name=\"label_import_job\"+str(uuid.uuid4()), \n",
665-
"# labels=labels)\n",
584+
"# Upload label for this data row in project \n",
585+
"upload_job_label_import = lb.LabelImport.create_from_objects(\n",
586+
" client = client, \n",
587+
" project_id = project.uid, \n",
588+
" name=\"label_import_job\"+str(uuid.uuid4()), \n",
589+
" labels=labels)\n",
666590
"\n",
667-
"# upload_job_label_import.wait_until_done();\n",
668-
"# print(\"Errors:\", upload_job_label_import.errors)\n",
669-
"# print(\"Status of uploads: \", upload_job_label_import.statuses)"
591+
"upload_job_label_import.wait_until_done()\n",
592+
"print(\"Errors:\", upload_job_label_import.errors)\n",
593+
"print(\"Status of uploads: \", upload_job_label_import.statuses)"
670594
],
671595
"cell_type": "code",
672596
"outputs": [],

0 commit comments

Comments
 (0)