Code Duplication    Length = 25-25 lines in 2 locations

src/ocrd_models/ocrd_page_generateds.py 1 location

@@ 3289-3313 (lines=25) @@
3286
        """
3287
        self.invalidate_AlternativeImage(feature_selector='cropped')
3288
        self.Border = Border
3289
    def get_AllTextLines(self, region_order='document', respect_textline_order=True):
3290
        """
3291
        Return all the TextLine in the document
3292
    
3293
        Arguments:
3294
            region_order ("document"|"reading-order"|"reading-order-only"): Whether to \
3295
                return regions sorted by document order (``document``, default) or by \
3296
                reading order with regions not in the reading order at the end of the \
3297
                returned list (``reading-order``) or regions not in the reading order \
3298
                omitted (``reading-order-only``)
3299
            respect_textline_order (boolean): Whether to respect `@textLineOrder` attribute
3300
    
3301
        Returns:
3302
            a list of :py:class:`TextLineType`
3303
        """
3304
        # TODO handle textLineOrder according to https://github.com/PRImA-Research-Lab/PAGE-XML/issues/26
3305
        ret = []
3306
        for reg in self.get_AllRegions(['Text'], order=region_order):
3307
            lines = reg.get_TextLine()
3308
            if not respect_textline_order:
3309
                ret += lines
3310
            else:
3311
                lo = reg.get_textLineOrder() or self.get_textLineOrder() or 'top-to-bottom'
3312
                ret += lines if lo in ['top-to-bottom', 'left-to-right'] else list(reversed(lines))
3313
        return ret
3314
    
3315
    def set_orientation(self, orientation):
3316
        """

src/ocrd_page_user_methods/get_AllTextLines.py 1 location

@@ 1-25 (lines=25) @@
1
def get_AllTextLines(self, region_order='document', respect_textline_order=True):
2
    """
3
    Return all the TextLine in the document
4
5
    Arguments:
6
        region_order ("document"|"reading-order"|"reading-order-only"): Whether to \
7
            return regions sorted by document order (``document``, default) or by \
8
            reading order with regions not in the reading order at the end of the \
9
            returned list (``reading-order``) or regions not in the reading order \
10
            omitted (``reading-order-only``)
11
        respect_textline_order (boolean): Whether to respect `@textLineOrder` attribute
12
13
    Returns:
14
        a list of :py:class:`TextLineType`
15
    """
16
    # TODO handle textLineOrder according to https://github.com/PRImA-Research-Lab/PAGE-XML/issues/26
17
    ret = []
18
    for reg in self.get_AllRegions(['Text'], order=region_order):
19
        lines = reg.get_TextLine()
20
        if not respect_textline_order:
21
            ret += lines
22
        else:
23
            lo = reg.get_textLineOrder() or self.get_textLineOrder() or 'top-to-bottom'
24
            ret += lines if lo in ['top-to-bottom', 'left-to-right'] else list(reversed(lines))
25
    return ret
26
27