INNER CODE UNIT · Python

_get_sources_to_aggregate

NorskRegnesentral/skweak · skweak/aggregation.py:164

    def _get_sources_to_aggregate(self, doc):
        """Returns the sources to consider (and filtering out the ones to avoid, 
        such as aggretated sources)"""
        sources = [source for source in doc.spans if len(doc.spans[source]) > 0
                   and not doc.spans[source].attrs.get("aggregated", False)
                   and not doc.spans[source].attrs.get("avoid_in_aggregation", False)
                   and (not hasattr(self, "weights") 
                        or np.sum(self.weights.get(source, 1)) > 0) #type:ignore
                    and (not hasattr(self, "initial_weights") 
                        or self.initial_weights.get(source, 1) > 0)] #type:ignore
        return sources    


    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…