INNER CODE UNIT · Python
data
NorskRegnesentral/skweak · skweak/aggregation.py:280
data = np.full((len(unique_spans), len(sources)),fill_value=-1, dtype=np.int16)
observed_labels = self.observed_labels
# Populating the array with the labels from each source
label_indices = {l: i for i, l in enumerate(observed_labels)}
for source_index, source in enumerate(sources):
for span in doc.spans[source]:
if span.label_ in observed_labels:
span_index = spans_indices[(span.start, span.end)]
data[span_index, source_index] = label_indices[span.label_]
# We only consider spans with at least one concrete prediction
masking = np.full(len(unique_spans), fill_value=True, dtype=bool)
for i, row in enumerate(data):
if row.max() < 0:
masking[i] = False
data = data[masking]