Ejemplo n.º 1
0
    def align(self, p1, p2, index):
        """
        Yields predictions of alignments.

        Parameters
        ----------
        p1, p2 : A pair of Page's
            The two pages to be aligned

        index :
            An identifiers of the pair.
        """
        t = [p1.y, p2.y]
        for op in im_utils.fuzzy_box_align(p1.y, p2.y):
            if op[0] != "equal":
                range = Range.from_op(op)
                side = 0 if r[0].num_lines() > r[1].num_lines() else 1
                # for box in boxes[side][r[side].start.line:r[side].end.line]:
                #     images.draw_box(ims[side], box)
                text = 0 #no text prediction
                position = t[side][r[side].start.line].y
                # Assume we are looking at line index for predictions.
                yield Prediction(index, side,
                                 text,
                                 position,
                                 range[side])
Ejemplo n.º 2
0
    def align(self, p1, p2, index):
        """
        Yields predictions of alignments.

        Parameters
        ----------
        p1, p2 : A pair of Page's
        The two pages to be aligned

        index :
          An identifiers of the pair.
        """
        # align = dp.AlignAlgorithm(p1, p2)
        # t1, i1 = p1.x, p1.y
        # t2, i2 = p2.x, p2.y
        ops = text_utils.fuzzy_text_align(p1.x, p2.x)
        t = [p1.x, p2.x]
        for op in ops:
            if op[0] != "equal":
                r = Range.from_op(op)
                side = 0 if r[0].num_lines() > r[1].num_lines() else 1
                yield Prediction(index, side,
                                 r[side].text_from_range(t[side]),
                                 0, r[side])