mirror of
https://github.com/qurator-spk/page2tsv.git
synced 2025-06-30 21:59:54 +02:00
cli: separate tsv2page and tsv2page_cli
This commit is contained in:
parent
fe0c355e5a
commit
0aee20a7f6
2 changed files with 12 additions and 9 deletions
6
setup.py
6
setup.py
|
@ -22,8 +22,10 @@ setup(
|
||||||
'console_scripts': [
|
'console_scripts': [
|
||||||
"extract-doc-links=tsvtools.cli:extract_document_links",
|
"extract-doc-links=tsvtools.cli:extract_document_links",
|
||||||
"annotate-tsv=tsvtools.cli:annotate_tsv",
|
"annotate-tsv=tsvtools.cli:annotate_tsv",
|
||||||
"page2tsv=tsvtools.cli:page2tsv",
|
"ocrd-neat-export=tsvtools.ocrd_cli:export_cli",
|
||||||
"tsv2page=tsvtools.cli:tsv2page",
|
"ocrd-neat-import=tsvtools.ocrd_cli:import_cli",
|
||||||
|
"page2tsv=tsvtools.cli:page2tsv_cli",
|
||||||
|
"tsv2page=tsvtools.cli:tsv2page_cli",
|
||||||
"make-page2tsv-commands=tsvtools.cli:make_page2tsv_commands"
|
"make-page2tsv-commands=tsvtools.cli:make_page2tsv_commands"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
@ -159,13 +159,6 @@ def page2tsv(page_xml_file, tsv_out_file, purpose, image_url, ner_rest_endpoint,
|
||||||
except requests.HTTPError as e:
|
except requests.HTTPError as e:
|
||||||
print(e)
|
print(e)
|
||||||
|
|
||||||
|
|
||||||
@click.command()
|
|
||||||
@click.option('--output-filename', '-o', help="Output filename. "
|
|
||||||
"If omitted, PAGE-XML filename with .corrected.xml extension")
|
|
||||||
@click.option('--keep-words', '-k', is_flag=True, help="Keep (out-of-date) Words of TextLines")
|
|
||||||
@click.argument('page-file')
|
|
||||||
@click.argument('tsv-file')
|
|
||||||
def tsv2page(output_filename, keep_words, page_file, tsv_file):
|
def tsv2page(output_filename, keep_words, page_file, tsv_file):
|
||||||
if not output_filename:
|
if not output_filename:
|
||||||
output_filename = Path(page_file).stem + '.corrected.xml'
|
output_filename = Path(page_file).stem + '.corrected.xml'
|
||||||
|
@ -181,6 +174,14 @@ def tsv2page(output_filename, keep_words, page_file, tsv_file):
|
||||||
with open(output_filename, 'w', encoding='utf-8') as f:
|
with open(output_filename, 'w', encoding='utf-8') as f:
|
||||||
f.write(ET.tostring(tree, pretty_print=True).decode('utf-8'))
|
f.write(ET.tostring(tree, pretty_print=True).decode('utf-8'))
|
||||||
|
|
||||||
|
@click.command()
|
||||||
|
@click.option('--output-filename', '-o', help="Output filename. "
|
||||||
|
"If omitted, PAGE-XML filename with .corrected.xml extension")
|
||||||
|
@click.option('--keep-words', '-k', is_flag=True, help="Keep (out-of-date) Words of TextLines")
|
||||||
|
@click.argument('page-file')
|
||||||
|
@click.argument('tsv-file')
|
||||||
|
def tsv2page_cli(output_filename, keep_words, page_file, tsv_file):
|
||||||
|
return tsv2page_cli(output_filename, keep_words, page_file, tsv_file)
|
||||||
|
|
||||||
@click.command()
|
@click.command()
|
||||||
@click.option('--xls-file', type=click.Path(exists=True), default=None,
|
@click.option('--xls-file', type=click.Path(exists=True), default=None,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue