Skip to content

Instantiators

instantiate_annotators(annotators_cfg, taxonomy)

Instantiates the annotators from the configuration.

Parameters:

Name Type Description Default
annotators_cfg DictConfig
required
taxonomy
required

Returns:

Type Description
List[Annotator]
Source code in src/utils/instantiators.py
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
def instantiate_annotators(annotators_cfg: DictConfig, taxonomy) -> List[Annotator]:
    """
    Instantiates the annotators from the configuration.
    :param annotators_cfg:
    :param taxonomy:
    :return:
    """
    annotators: List[Annotator] = []

    for name, cb_conf in annotators_cfg.items():
        if isinstance(cb_conf, DictConfig):
            logger.info(f"Instantiating annotator <{name}>")
            lf = instantiate(cb_conf['lf'], taxonomy=taxonomy)
            filtering = instantiate(cb_conf['filtering']) if cb_conf['filtering']['_target_'] else None
            transformation = instantiate(cb_conf['transformation']) if cb_conf['transformation']['_target_'] else None
            annotators.append(Annotator(lf, filtering, transformation))

    return annotators