Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 35 additions & 63 deletions examples/annotation_import/text.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -86,33 +86,19 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 36,
"id": "4d63074b-2379-48af-b9d6-2a66190f03c4",
"metadata": {
"id": "4d63074b-2379-48af-b9d6-2a66190f03c4",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "0b4547c9-e534-441d-9bf6-7588ee50c8a2"
"id": "4d63074b-2379-48af-b9d6-2a66190f03c4"
},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"\u001b[K |████████████████████████████████| 184 kB 5.2 MB/s \n",
"\u001b[K |████████████████████████████████| 7.8 MB 45.4 MB/s \n",
"\u001b[?25h Building wheel for pygeotile (setup.py) ... \u001b[?25l\u001b[?25hdone\n"
]
}
],
"outputs": [],
"source": [
"!pip install -q 'labelbox[data]'"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 37,
"id": "01fca8c9-0680-4a9c-a11e-1b49f31e9121",
"metadata": {
"id": "01fca8c9-0680-4a9c-a11e-1b49f31e9121"
Expand Down Expand Up @@ -144,7 +130,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 38,
"id": "86003724-4807-4281-95c1-5284a6f9609f",
"metadata": {
"id": "86003724-4807-4281-95c1-5284a6f9609f"
Expand Down Expand Up @@ -199,7 +185,7 @@
"id": "Z5ORHD1pZKt1"
},
"id": "Z5ORHD1pZKt1",
"execution_count": null,
"execution_count": 39,
"outputs": []
},
{
Expand All @@ -226,26 +212,13 @@
"id": "mrPJ1Ko0ZMdl"
},
"id": "mrPJ1Ko0ZMdl",
"execution_count": null,
"execution_count": 40,
"outputs": []
},
{
"cell_type": "code",
"source": [
"########## Classification - Radio (with subclassifcations) ##########\n",
"\n",
"# Python annotation\n",
"radio_annotation_nested = ClassificationAnnotation(\n",
" name=\"radio_question_sub\", \n",
" value=Radio(answer = ClassificationAnswer(name = \"first_radio_answer\")),\n",
" classifications=[\n",
" \tClassificationAnnotation(\n",
" \tname=\"sub_radio_question\",\n",
" \t\tvalue=Radio(answer=ClassificationAnswer(name=\"first_sub_radio_answer\"))\n",
" )\n",
" ]\n",
")\n",
"\n",
"########## Classification - Radio (with subclassifcations) is only suppported with NDJSON tools ##########\n",
"\n",
"# NDJSON\n",
"radio_annotation_ndjson_with_subclass = {\n",
Expand All @@ -263,7 +236,7 @@
"id": "vt7QvfV7ZPAF"
},
"id": "vt7QvfV7ZPAF",
"execution_count": null,
"execution_count": 41,
"outputs": []
},
{
Expand Down Expand Up @@ -296,12 +269,12 @@
"id": "45BDh768ZYsH"
},
"id": "45BDh768ZYsH",
"execution_count": null,
"execution_count": 42,
"outputs": []
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 43,
"id": "f9f9287c-aad7-4914-bc87-1453fb8bce81",
"metadata": {
"id": "f9f9287c-aad7-4914-bc87-1453fb8bce81"
Expand Down Expand Up @@ -364,27 +337,27 @@
"base_uri": "https://localhost:8080/"
},
"id": "Ak-jnABK3OPH",
"outputId": "ff481cce-af08-4748-e8ac-a959085e07de"
"outputId": "0f80ba52-adde-4d97-d04a-fcdbe4d1a414"
},
"id": "Ak-jnABK3OPH",
"execution_count": null,
"execution_count": 44,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"<DataRow {\n",
" \"created_at\": \"2022-12-22 20:59:28+00:00\",\n",
" \"created_at\": \"2023-01-30 18:06:23+00:00\",\n",
" \"external_id\": null,\n",
" \"global_key\": \"TEST-ID-190217471490724126308456269288159181446d\",\n",
" \"global_key\": \"TEST-ID-321668750509639104503407808903937477958d\",\n",
" \"media_attributes\": {},\n",
" \"metadata\": [],\n",
" \"metadata_fields\": [],\n",
" \"row_data\": \"https://storage.googleapis.com/labelbox-sample-datasets/nlp/lorem-ipsum.txt\",\n",
" \"uid\": \"clbzkhbxy18ws07ysdumbbgnq\",\n",
" \"updated_at\": \"2022-12-22 20:59:28+00:00\"\n",
" \"uid\": \"cldj4gyf60fy207xh3z1y2g1h\",\n",
" \"updated_at\": \"2023-01-30 18:06:23+00:00\"\n",
"}>\n",
"clbzkhbxy18ws07ysdumbbgnq\n"
"cldj4gyf60fy207xh3z1y2g1h\n"
]
}
]
Expand All @@ -395,7 +368,7 @@
"### Step 2: Create/select an ontology\n",
"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",
"\n",
"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",
"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",
"\n",
"[Documentation for reference ](https://docs.labelbox.com/reference/import-text-annotations)"
],
Expand Down Expand Up @@ -459,7 +432,7 @@
"id": "_wWxYFoDTsar"
},
"id": "_wWxYFoDTsar",
"execution_count": null,
"execution_count": 45,
"outputs": []
},
{
Expand All @@ -475,7 +448,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 46,
"id": "044e9194-d21d-403e-b64c-047c1063b0fe",
"metadata": {
"id": "044e9194-d21d-403e-b64c-047c1063b0fe"
Expand Down Expand Up @@ -537,22 +510,22 @@
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "153857ae-455d-4c7c-fb36-40fc16dc0819"
"outputId": "6eb66aad-477d-490e-ea91-53de995f1f65"
},
"id": "DbwheC8RzI-0",
"execution_count": null,
"execution_count": 47,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Batch: <Batch {\n",
" \"consensus_settings_json\": \"{\\\"numberOfLabels\\\":1,\\\"coveragePercentage\\\":0}\",\n",
" \"created_at\": \"2022-12-22 20:59:51+00:00\",\n",
" \"created_at\": \"2023-01-30 18:06:28+00:00\",\n",
" \"name\": \"first-batch-text-demo\",\n",
" \"size\": 1,\n",
" \"uid\": \"94297660-823b-11ed-8039-c1b641c04d88\",\n",
" \"updated_at\": \"2022-12-22 20:59:51+00:00\"\n",
" \"uid\": \"d14be9f0-a0c8-11ed-a7e5-f9da6146996d\",\n",
" \"updated_at\": \"2023-01-30 18:06:28+00:00\"\n",
"}>\n"
]
}
Expand All @@ -575,7 +548,7 @@
{
"cell_type": "markdown",
"source": [
"#### Python Annotations"
"#### Python annotations"
],
"metadata": {
"id": "7IgSl5SxcO4R"
Expand All @@ -584,7 +557,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 48,
"id": "53aaf87b-114f-4b56-a417-8c7cddc1f532",
"metadata": {
"id": "53aaf87b-114f-4b56-a417-8c7cddc1f532"
Expand All @@ -599,8 +572,7 @@
" named_entitity_annotation, \n",
" radio_annotation, \n",
" checklist_annotation, \n",
" text_annotation, \n",
" radio_annotation_nested \n",
" text_annotation\n",
" ]\n",
")\n",
"\n",
Expand Down Expand Up @@ -628,7 +600,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 49,
"id": "c66672c7-33e8-4d5d-b79d-2ac76d830341",
"metadata": {
"id": "c66672c7-33e8-4d5d-b79d-2ac76d830341"
Expand Down Expand Up @@ -693,10 +665,10 @@
"base_uri": "https://localhost:8080/"
},
"id": "izli4zhEfi75",
"outputId": "b1cdc2d0-9541-4df2-d922-be0a7ce80499"
"outputId": "4eb1b790-4e60-4cc6-9224-de6a9ed339bf"
},
"id": "izli4zhEfi75",
"execution_count": null,
"execution_count": 50,
"outputs": [
{
"output_type": "stream",
Expand All @@ -720,14 +692,14 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 51,
"id": "e8d4e99b-ad7e-48b9-8073-afb764d7c5b4",
"metadata": {
"id": "e8d4e99b-ad7e-48b9-8073-afb764d7c5b4",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "be9df775-f18c-44ed-e02e-82b3c2a3691f"
"outputId": "1e52b23b-cefc-439b-f374-2e8b886280f4"
},
"outputs": [
{
Expand Down Expand Up @@ -770,7 +742,7 @@
"id": "ubbraAmo2_fe"
},
"id": "ubbraAmo2_fe",
"execution_count": null,
"execution_count": 52,
"outputs": []
}
],
Expand Down