def _read_annotations()

in sagemaker/src/htr_dataset.py [0:0]


    def _read_annotations(self, annotation_path, output_type):
        '''
        Given an annotation path
        '''
        annotations = []
        with open(annotation_path, "r") as w:
            lines = w.readlines()
            for line in lines:
                if len(line) <= 1:
                    continue
                annotation_dict = json.loads(line) #json.loads(line[:-1])
                if output_type == "line":
                    line_annotations = self._read_line_annotation(annotation_dict)
                    for line_annotation in line_annotations:
                        annotations.append(line_annotation)
                elif output_type == "word":
                    word_annotations = self._read_word_annotations(annotation_dict)
                    for word_annotation in word_annotations:
                        annotations.append(word_annotation)
                elif output_type == "page":
                    annotation = self._read_page_annotation(annotation_dict)
                    annotations.append(annotation)
        return annotations