Skip to content

Reading annotations in Document Metadata #24

@Rachneet

Description

@Rachneet

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions