Skip to content

Commit

Permalink
refactor line2page
Browse files Browse the repository at this point in the history
  • Loading branch information
maxnth committed Jul 1, 2022
1 parent f39921f commit 8ab6acd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
13 changes: 6 additions & 7 deletions pagetools/cli/transformations/line2page.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,21 @@
import click


@click.command("line2page", help="Links line images and corresponding texts in a page and creates a combined image and "
"XML-File of each page")
@click.option('-c', '--creator', type=str, default='user', help='Creator tag for PAGE XML', show_default=True)
@click.command("line2page", help="Merges line images and line texts into combined images and XML files")
@click.option('-c', '--creator', type=str, default='PAGETools', help='Creator tag for PAGE XML', show_default=True)
@click.option('-s', '--source-folder', type=str, required=True, help='Path to images and GT')
@click.option('-i', '--image-folder', default='', type=str, help='Path to images', show_default=True)
@click.option('-gt', '--gt-folder', default='', type=str, help='Path to GT', show_default=True)
@click.option('-d', '--dest-folder', default=Path(Path.cwd(), 'merged'), type=str, help='Path to merge objects',
@click.option('-d', '--dest-folder', default=Path(Path.cwd(), 'merged'), type=str, help='Path where output gets stored',
show_default=True)
@click.option('-e', '--ext', default='.bin.png', type=str, help='Image extension', show_default=True)
@click.option('-p', '--pred', default=False, type=bool, help='Set flag to also store .pred.txt', show_default=True)
@click.option('-p', '--pred', default=False, is_flag=True, help='Sets flag to also include .pred.txt', show_default=True)
@click.option('-l', '--lines', default=20, type=click.IntRange(min=0, clamp=True), help='Lines per page',
show_default=True)
@click.option('-ls', '--line-spacing', default=5, type=click.IntRange(min=0, clamp=True),
help='Spacing between lines in pixel', show_default=True)
help='Spacing between lines (in pixel)', show_default=True)
@click.option('-b', '--border', nargs=4, default=(10, 10, 10, 10), type=click.IntRange(min=0, clamp=True),
help='Border in pixel: top bottom left right', show_default=True)
help='Border (in pixel): TOP BOTTOM LEFT RIGHT', show_default=True)
@click.option('--debug', default='20', type=click.Choice(['10', '20', '30', '40', '50']),
help='Sets the level of feedback to receive: DEBUG=10, INFO=20, WARNING=30, ERROR=40, CRITICAL=50',
show_default=True)
Expand Down
4 changes: 2 additions & 2 deletions pagetools/src/line2page/Line2Page.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def chunks(lst: list, n: int):
yield lst[i: i + n]

@staticmethod
def name_pages(pages: List[str]) -> List[str]:
def name_pages(pages: List[str]) -> List[List[str]]:
"""Returns a list of all objects in pages with pagename followed by a 4-digit pagenumber"""
page_with_name = []
pages_with_name = []
Expand Down Expand Up @@ -138,7 +138,7 @@ def make_page(self, page_with_name, semaphore):
semaphore.release()

def match_files(self):
"""Pairs image with gt-Text and adds the pairing to matches"""
"""Pairs image with GT text and adds the pairing to matches"""
for img in self.imgList:
pairing = []
img_name = Path(img.split('.')[0]).name
Expand Down

0 comments on commit 8ab6acd

Please sign in to comment.