Pre-annotations of text entities with radio sub-classifications

I have a text ontology where entities can have subclassfications. For example I can have a entity class named ‘anatomy’ with radio subclassification called ‘anatomy_type’ options (“arm”, “heart”) and another entity named “test” with free text subclassifcation called “value”.

How can I upload annotations with subclassifcations as a MALPredictionImport? I could not find code examples in the documentation. I can upload just the entites fine, but when I try with subclassifications nothing is pre-annotated.

Hello @mgarranzo ,

We do have more technical documentation on the Dev Guides and given your use case I found this (this just a sample so you would need to change according to your needs) :


############ NER with nested classifications ######## 


ner_with_checklist_subclass_annotation = lb_types.ObjectAnnotation(
  name="ner_with_checklist_subclass",
  value=lb_types.DocumentEntity(
    name="ner_with_checklist_subclass",
    text_selections=[
      lb_types.DocumentTextSelection(
        token_ids=[],
        group_id="",
        page=1
      )
    ]
  ),
  classifications=[
    lb_types.ClassificationAnnotation(
      name="sub_checklist_question",
      value=lb_types.Checklist(
      answer=[lb_types.ClassificationAnswer(name="first_sub_checklist_answer")]
      )
    )
  ]
)

You can find more here : labelbox-python/examples/annotation_import/pdf.ipynb at develop · Labelbox/labelbox-python · GitHub

Many thanks,
PT

1 Like