INNER CODE UNIT · Python

__init__

NorskRegnesentral/skweak · skweak/aggregation.py:336

    def __init__(self, prefixes: str = "BIO"):
        """Do not call this initializer directly, and use the fully
        implemented classes (MajorityVoter, NaiveBayes, HMM, etc.) instead"""

        if prefixes not in {"IO", "BIO", "BILUO", "BILOU"}:
            raise RuntimeError(
                "Tagging scheme must be 'IO', 'BIO', 'BILUO' or ''")
        
        # We add prefixes to the labels (i.e. "B-ORG" etc)
        prefixed_labels = ["O"]
        for label in self.out_labels:
            if any(label.startswith("%s-"%p) for p in "BILU"):
                raise RuntimeError("Initial labels should not have a prefix")
            for prefix in prefixes.replace("O", ""):
                prefixed_labels.append("%s-%s" % (prefix, label))
        
        self.prefixes = prefixes    
        self.out_labels_no_prefixes=list(self.out_labels)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…