|
140 | 140 | " )\n", |
141 | 141 | ")\n", |
142 | 142 | "\n", |
143 | | - "ner_annotation_ndjson = { \n", |
| 143 | + "ner_annotation_ndjson = {\n", |
144 | 144 | " \"name\": \"ner\",\n", |
145 | | - " \"location\": { \n", |
146 | | - " \"start\": 0, \n", |
147 | | - " \"end\": 8 \n", |
| 145 | + " \"location\": {\n", |
| 146 | + " \"start\": 0,\n", |
| 147 | + " \"end\": 8\n", |
148 | 148 | " },\n", |
149 | 149 | " \"messageId\": \"4\"\n", |
150 | 150 | " }" |
|
178 | 178 | { |
179 | 179 | "metadata": {}, |
180 | 180 | "source": [ |
181 | | - "##### Checklist Classification ####### \n", |
| 181 | + "##### Checklist Classification #######\n", |
182 | 182 | "\n", |
183 | 183 | "checklist_annotation= lb_types.ClassificationAnnotation(\n", |
184 | 184 | " name=\"checklist_convo\", # must match your ontology feature\"s name\n", |
185 | 185 | " value=lb_types.Checklist(\n", |
186 | 186 | " answer = [\n", |
187 | 187 | " lb_types.ClassificationAnswer(\n", |
188 | 188 | " name = \"first_checklist_answer\"\n", |
189 | | - " ), \n", |
| 189 | + " ),\n", |
190 | 190 | " lb_types.ClassificationAnswer(\n", |
191 | 191 | " name = \"second_checklist_answer\"\n", |
192 | 192 | " )\n", |
|
215 | 215 | "######## Radio Classification ######\n", |
216 | 216 | "\n", |
217 | 217 | "radio_annotation = lb_types.ClassificationAnnotation(\n", |
218 | | - " name=\"radio_convo\", \n", |
| 218 | + " name=\"radio_convo\",\n", |
219 | 219 | " value=lb_types.Radio(answer = lb_types.ClassificationAnswer(name = \"first_radio_answer\")),\n", |
220 | 220 | " message_id=\"0\"\n", |
221 | 221 | ")\n", |
|
264 | 264 | " \"name\": \"first_checklist_answer\",\n", |
265 | 265 | " \"classifications\" : [\n", |
266 | 266 | " {\n", |
267 | | - " \"name\": \"sub_checklist_question\", \n", |
| 267 | + " \"name\": \"sub_checklist_question\",\n", |
268 | 268 | " \"answer\": {\n", |
269 | 269 | " \"name\": \"first_sub_checklist_answer\"\n", |
270 | 270 | " }\n", |
271 | | - " } \n", |
272 | | - " ] \n", |
| 271 | + " }\n", |
| 272 | + " ]\n", |
273 | 273 | " }]\n", |
274 | 274 | "}\n", |
275 | 275 | "# Global\n", |
|
360 | 360 | "metadata": {}, |
361 | 361 | "source": [ |
362 | 362 | "ontology_builder = lb.OntologyBuilder(\n", |
363 | | - " tools=[ \n", |
| 363 | + " tools=[\n", |
364 | 364 | " lb.Tool(tool=lb.Tool.Type.NER,name=\"ner\"),\n", |
365 | | - " ], \n", |
366 | | - " classifications=[ \n", |
367 | | - " lb.Classification( \n", |
| 365 | + " ],\n", |
| 366 | + " classifications=[\n", |
| 367 | + " lb.Classification(\n", |
368 | 368 | " class_type=lb.Classification.Type.TEXT,\n", |
369 | | - " scope=lb.Classification.Scope.INDEX, \n", |
370 | | - " name=\"text_convo\"), \n", |
371 | | - " lb.Classification( \n", |
372 | | - " class_type=lb.Classification.Type.CHECKLIST, \n", |
373 | | - " scope=lb.Classification.Scope.INDEX, \n", |
374 | | - " name=\"checklist_convo\", \n", |
| 369 | + " scope=lb.Classification.Scope.INDEX,\n", |
| 370 | + " name=\"text_convo\"),\n", |
| 371 | + " lb.Classification(\n", |
| 372 | + " class_type=lb.Classification.Type.CHECKLIST,\n", |
| 373 | + " scope=lb.Classification.Scope.INDEX,\n", |
| 374 | + " name=\"checklist_convo\",\n", |
375 | 375 | " options=[\n", |
376 | 376 | " lb.Option(value=\"first_checklist_answer\"),\n", |
377 | | - " lb.Option(value=\"second_checklist_answer\") \n", |
| 377 | + " lb.Option(value=\"second_checklist_answer\")\n", |
378 | 378 | " ]\n", |
379 | | - " ), \n", |
380 | | - " lb.Classification( \n", |
381 | | - " class_type=lb.Classification.Type.RADIO, \n", |
382 | | - " name=\"radio_convo\", \n", |
383 | | - " scope=lb.Classification.Scope.INDEX, \n", |
| 379 | + " ),\n", |
| 380 | + " lb.Classification(\n", |
| 381 | + " class_type=lb.Classification.Type.RADIO,\n", |
| 382 | + " name=\"radio_convo\",\n", |
| 383 | + " scope=lb.Classification.Scope.INDEX,\n", |
384 | 384 | " options=[\n", |
385 | 385 | " lb.Option(value=\"first_radio_answer\"),\n", |
386 | 386 | " lb.Option(value=\"second_radio_answer\")\n", |
|
395 | 395 | " options=[\n", |
396 | 396 | " lb.Classification(\n", |
397 | 397 | " class_type=lb.Classification.Type.CHECKLIST,\n", |
398 | | - " name=\"sub_checklist_question\", \n", |
| 398 | + " name=\"sub_checklist_question\",\n", |
399 | 399 | " options=[lb.Option(\"first_sub_checklist_answer\")]\n", |
400 | 400 | " )\n", |
401 | 401 | " ])\n", |
|
438 | 438 | "metadata": {}, |
439 | 439 | "source": [ |
440 | 440 | "# Create Labelbox project\n", |
441 | | - "project = client.create_project(name=\"Conversational Text Annotation Import Demo\", \n", |
| 441 | + "project = client.create_project(name=\"Conversational Text Annotation Import Demo\",\n", |
442 | 442 | " media_type=lb.MediaType.Conversational)\n", |
443 | 443 | "\n", |
444 | | - "# Setup your ontology \n", |
| 444 | + "# Setup your ontology\n", |
445 | 445 | "project.setup_editor(ontology) # Connect your ontology and editor to your project" |
446 | 446 | ], |
447 | 447 | "cell_type": "code", |
|
458 | 458 | { |
459 | 459 | "metadata": {}, |
460 | 460 | "source": [ |
461 | | - "# Setup Batches and Ontology\n", |
462 | | - "\n", |
463 | 461 | "# Create a batch to send to your MAL project\n", |
464 | 462 | "batch = project.create_batch(\n", |
465 | 463 | " \"first-batch-convo-demo\", # Each batch in a project must have a unique name\n", |
|
566 | 564 | "source": [ |
567 | 565 | "# Upload our label using Model-Assisted Labeling\n", |
568 | 566 | "upload_job = lb.MALPredictionImport.create_from_objects(\n", |
569 | | - " client = client, \n", |
570 | | - " project_id = project.uid, \n", |
571 | | - " name=f\"mal_job-{str(uuid.uuid4())}\", \n", |
| 567 | + " client = client,\n", |
| 568 | + " project_id = project.uid,\n", |
| 569 | + " name=f\"mal_job-{str(uuid.uuid4())}\",\n", |
572 | 570 | " predictions=label)\n", |
573 | 571 | "\n", |
574 | 572 | "upload_job.wait_until_done()\n", |
|
589 | 587 | { |
590 | 588 | "metadata": {}, |
591 | 589 | "source": [ |
592 | | - "# Upload label for this data row in project \n", |
| 590 | + "# Upload label for this data row in project\n", |
593 | 591 | "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", |
| 592 | + " client = client,\n", |
| 593 | + " project_id = project.uid,\n", |
| 594 | + " name=\"label_import_job\"+str(uuid.uuid4()),\n", |
597 | 595 | " labels=label)\n", |
598 | 596 | "\n", |
599 | 597 | "upload_job.wait_until_done()\n", |
|
0 commit comments