inceptalytics
inceptalytics copied to clipboard
Reading annotations in Document Metadata
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)
Does it work if you use the layer, not the feature path?
Nope, it doesn't.
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.