INNER CODE UNIT · Python
SequenceAggregatorMixin
NorskRegnesentral/skweak · skweak/aggregation.py:331
class SequenceAggregatorMixin(AbstractAggregator):
"""Implementation of a subset of methods from AbstractAggregator when
the aggregation is performed for token-level sequence labelling.
This class should not be instantiated directly"""
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")