INNER CODE UNIT · Python

set_exclusive_labels

NorskRegnesentral/skweak · skweak/aggregation.py:428

    def set_exclusive_labels(self, exclusive_labels:Set[str]):
        """Defines a set of labels that are mutually exclusive (i.e. they cannot 
        simultaneously co-occur for the same data point)"""
        
        for label, model in self.models.items():
            if label in exclusive_labels:
                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.)"""

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…