catalpa-cl / inceptalytics

An easy-to-use API for analyzing INCEpTION annotation projects.
16 stars 7 forks source link

Reading annotations in Document Metadata #24

Open Rachneet opened 1 year ago

Rachneet commented 1 year ago

Outline

We have some annotations in the document metadata that we want to access. But the project view does not include them and gives an empty result.

Description:

We have a layer for answer preference where the user chooses between 2 answers and gives a reason. The layer is of type Document metadata since the annotation is document-level.

All our other layers are span-level and the library can read those out.

For this specific case,

preference_layer = "webanno.custom.Answerpreferencev1"
print(f'Features: {project.features(preference_layer)}')
feature = 'Reason'
feature_path = f'{preference_layer}>{feature}'

# select reduced view
reduced_pref_annos = project.select(
    annotation=feature_path,
    annotators=['jim', 'jam'],
    source_files=["x.txt", "y.txt"]
)

print('# pref. annotations in view:', reduced_pref_annos.count())
print('# annotations per file per annotator', reduced_pref_annos.count(grouped_by=['source_file', 'annotator']))

And the result is:

# pref. annotations in view: 0
# annotations per file per annotator Series([], Name: annotation, dtype: int64)
zesch commented 1 year ago

Does it work if you use the layer, not the feature path?

Rachneet commented 1 year ago

Nope, it doesn't.

zesch commented 1 year ago

you are right, the way how we currently parse the inception project into our internal format only works for span annotations. We are working on a fix. Thanks for bringing this up.