INNER CODE UNIT · Python
other_labels
NorskRegnesentral/skweak · skweak/aggregation.py:434
other_labels = exclusive_labels - {label}
if hasattr(self, "prefixes"):
other_labels = {f"{p}-{other_label}" for p in self.prefixes if p!="O" #type: ignore
for other_label in other_labels}
model.add_label_group("O", other_labels)
else:
model.add_label_group(f"NOT/{label}", other_labels)
def add_label_group(self, coarse_label:str, sub_labels:Set[str]):
"""Specifies that a "coarse" label is a placeholder for several possible
fine-grained labels. For instance, an ENT label may be a placeholder
for multiple labels (PER, ORG, etc.)"""
for model in self.models.values():
model.add_label_group(coarse_label, sub_labels)
def aggregate(self, obs: pandas.DataFrame) -> pandas.DataFrame:
"""Takes as input a 2D dataframe of shape (nb_entries, nb_sources)