INNER CODE UNIT · Python
TextAggregatorMixin
NorskRegnesentral/skweak · skweak/aggregation.py:262
class TextAggregatorMixin(AbstractAggregator):
"""Implementation of a subset of methods from AbstractAggregator when
the aggregation is performed for text/span classification.
This class should not be instantiated directly."""
def get_observation_df(self, doc: Doc):
"""Returns a dataframe containing the observed predictions of each labelling
sources for the document. The content of the dataframe depends on the prefixes.
The dataframe has one row per unique spans."""
# Extracting the sources to consider (and filtering out the ones to avoid)
sources = self._get_sources_to_aggregate(doc)
# Extracts a list of unique spans (with identical boundaries)
unique_spans = set((span.start, span.end)
for s in sources for span in doc.spans[s])
sorted_spans = sorted(unique_spans)
spans_indices = {span: i for i, span in enumerate(sorted_spans)}