Skip to content

Commit fa0db9a

Browse files
ovalle15ovalle15
authored andcommitted
Added classification with annotation types for convo
1 parent 7e27e54 commit fa0db9a

File tree

1 file changed

+45
-8
lines changed

1 file changed

+45
-8
lines changed

examples/annotation_import/conversational.ipynb

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,16 @@
115115
"client = lb.Client(api_key=API_KEY)"
116116
],
117117
"cell_type": "code",
118-
"outputs": [],
118+
"outputs": [
119+
{
120+
"ename": "SyntaxError",
121+
"evalue": "unterminated string literal (detected at line 2) (1881836202.py, line 2)",
122+
"output_type": "error",
123+
"traceback": [
124+
"\u001b[0;36m Cell \u001b[0;32mIn[81], line 2\u001b[0;36m\u001b[0m\n\u001b[0;31m API_KEY = \"\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m unterminated string literal (detected at line 2)\n"
125+
]
126+
}
127+
],
119128
"execution_count": null
120129
},
121130
{
@@ -163,7 +172,13 @@
163172
"source": [
164173
"##### Classification free text #####\n",
165174
"\n",
166-
"# Only supported with NDJSON\n",
175+
"text_annotation = lb_types.ClassificationAnnotation(\n",
176+
" name=\"text_convo\",\n",
177+
" value=lb_types.Text(answer=\"the answer to the text questions right here\"),\n",
178+
" message_id=\"0\"\n",
179+
")\n",
180+
"\n",
181+
"\n",
167182
"text_annotation_ndjson = {\n",
168183
" 'name': 'text_convo',\n",
169184
" 'answer': 'the answer to the text questions right here',\n",
@@ -179,7 +194,22 @@
179194
"source": [
180195
"##### Checklist Classification ####### \n",
181196
"\n",
182-
"# Only supported with NDJSON\n",
197+
"checklist_annotation= lb_types.ClassificationAnnotation(\n",
198+
" name=\"checklist_convo\", # must match your ontology feature's name\n",
199+
" value=lb_types.Checklist(\n",
200+
" answer = [\n",
201+
" lb_types.ClassificationAnswer(\n",
202+
" name = \"first_checklist_answer\"\n",
203+
" ), \n",
204+
" lb_types.ClassificationAnswer(\n",
205+
" name = \"second_checklist_answer\"\n",
206+
" )\n",
207+
" ]\n",
208+
" ),\n",
209+
" message_id=\"2\"\n",
210+
" )\n",
211+
"\n",
212+
"\n",
183213
"checklist_annotation_ndjson = {\n",
184214
" 'name': 'checklist_convo',\n",
185215
" 'answers': [\n",
@@ -198,7 +228,12 @@
198228
"source": [
199229
"######## Radio Classification ######\n",
200230
"\n",
201-
"# Only supported with NDJSON\n",
231+
"radio_annotation = lb_types.ClassificationAnnotation(\n",
232+
" name='radio_convo', \n",
233+
" value=lb_types.Radio(answer = lb_types.ClassificationAnswer(name = 'first_radio_answer')),\n",
234+
" message_id=\"0\"\n",
235+
")\n",
236+
"\n",
202237
"radio_annotation_ndjson = {\n",
203238
" 'name': 'radio_convo',\n",
204239
" 'answer': {\n",
@@ -374,7 +409,10 @@
374409
" global_key=global_key\n",
375410
" ),\n",
376411
" annotations=[\n",
377-
" ner_annotation\n",
412+
" ner_annotation,\n",
413+
" text_annotation,\n",
414+
" checklist_annotation,\n",
415+
" radio_annotation\n",
378416
" ]\n",
379417
" )\n",
380418
")"
@@ -433,7 +471,7 @@
433471
" client = client, \n",
434472
" project_id = project.uid, \n",
435473
" name=f\"mal_job-{str(uuid.uuid4())}\", \n",
436-
" predictions=label_ndjson)\n",
474+
" predictions=label)\n",
437475
"\n",
438476
"upload_job.wait_until_done();\n",
439477
"print(\"Errors:\", upload_job.errors)\n",
@@ -458,8 +496,7 @@
458496
" client = client, \n",
459497
" project_id = project.uid, \n",
460498
" name=\"label_import_job\"+str(uuid.uuid4()), \n",
461-
" # user label_ndjson if labels were created using python annotation tools\n",
462-
" labels=label_ndjson)\n",
499+
" labels=label)\n",
463500
"\n",
464501
"upload_job.wait_until_done();\n",
465502
"print(\"Errors:\", upload_job.errors)\n",

0 commit comments

Comments
 (0)