INNER CODE UNIT · Python

add_label_group

NorskRegnesentral/skweak · skweak/aggregation.py:177

    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.)"""

        if coarse_label not in self.label_groups:
            self.label_groups[coarse_label] = set(sub_labels)
        else:
            self.label_groups[coarse_label].update(sub_labels)
            
        # Adding expansions of existing groups
        for other_coarse_label, other_sub_labels in self.label_groups.items():
            if other_coarse_label != coarse_label:
                for other_sub_label in list(other_sub_labels):
                    if other_sub_label==coarse_label:
                        other_sub_labels.update(sub_labels)
                        
        # And expansions based on existing groups

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…