INNER CODE UNIT · Python
__call__
NorskRegnesentral/skweak · skweak/aggregation.py:42
def __call__(self, doc: Doc) -> Doc:
"""Aggregates all weak supervision sources"""
# Extracting the sources to consider (and filtering out the ones to avoid)
sources = self._get_sources_to_aggregate(doc)
# If we have no labelling sources, we can skip the document
if len(sources)==0:
doc.spans[self.name] = []
doc.spans[self.name].attrs = {"probs":{}, "aggregated":True, "sources":[]}
return doc
# Extracting the observation data
df = self.get_observation_df(doc)
# Special case: if the document has no observation whatsoever
if len(df.columns)==0:
output_spans, output_probs = [], []