Skip to content

Annotator

Annotator

Class that performs the annotation of a file.

Source code in src/annotation/annotator.py
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
class Annotator:
    """
    Class that performs the annotation of a file.
    """
    def __init__(self, lf: LFBase, filtering: FilteringBase,
                 transformation: TransformationBase):
        """

        :param lf: Labelling function to be used to annotate the files.
        :param filtering: Filtering strategy to be used to mark as unannotated files with noisy annotations.
        :param transformation: Transformation to apply to the annotation vector.
        """
        self.lf = lf
        self.filtering = filtering
        self.transformation = transformation

    def annotate(self, name: str, content: str) -> np.array:

        label_vec = self.lf.annotate(name, content)

        unannotated = False
        if self.filtering:
            unannotated = self.filtering.filter(label_vec)

        if self.transformation and not unannotated:
            label_vec = self.transformation.transform(label_vec)

        if not np.linalg.norm(label_vec):
            unannotated = 1

        return label_vec, unannotated

__init__(lf, filtering, transformation)

Parameters:

Name Type Description Default
lf LFBase

Labelling function to be used to annotate the files.

required
filtering FilteringBase

Filtering strategy to be used to mark as unannotated files with noisy annotations.

required
transformation TransformationBase

Transformation to apply to the annotation vector.

required
Source code in src/annotation/annotator.py
12
13
14
15
16
17
18
19
20
21
22
def __init__(self, lf: LFBase, filtering: FilteringBase,
             transformation: TransformationBase):
    """

    :param lf: Labelling function to be used to annotate the files.
    :param filtering: Filtering strategy to be used to mark as unannotated files with noisy annotations.
    :param transformation: Transformation to apply to the annotation vector.
    """
    self.lf = lf
    self.filtering = filtering
    self.transformation = transformation