-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy path__main__.py
More file actions
48 lines (40 loc) · 1.76 KB
/
__main__.py
File metadata and controls
48 lines (40 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
"""
Package entry point for format converters.
This provides a menu to choose between TEI2LossyJSON and TEI2Markdown converters.
"""
import argparse
import sys
def main():
"""Main entry point that provides a menu for converter selection."""
# Check if a converter was specified
if len(sys.argv) < 2:
print("GROBID format converters - Choose a converter to run")
print("\nUsage:")
print(" python -m grobid_client.format <converter> [options]")
print("\nAvailable converters:")
print(" TEI2LossyJSON - Convert TEI XML to JSON format")
print(" TEI2Markdown - Convert TEI XML to Markdown format")
print("\nExamples:")
print(" python -m grobid_client.format TEI2LossyJSON --input file.tei.xml --output output.json")
print(" python -m grobid_client.format TEI2Markdown --input file.tei.xml --output output.md")
print("\nGet help for specific converter:")
print(" python -m grobid_client.format TEI2LossyJSON --help")
print(" python -m grobid_client.format TEI2Markdown --help")
sys.exit(1)
converter = sys.argv[1]
if converter == "TEI2LossyJSON":
from .TEI2LossyJSON_cli import main as lossy_main
# Replace sys.argv to pass remaining args to the converter
sys.argv = ["TEI2LossyJSON"] + sys.argv[2:]
lossy_main()
elif converter == "TEI2Markdown":
from .TEI2Markdown_cli import main as markdown_main
# Replace sys.argv to pass remaining args to the converter
sys.argv = ["TEI2Markdown"] + sys.argv[2:]
markdown_main()
else:
print(f"Unknown converter: {converter}")
print("Available converters: TEI2LossyJSON, TEI2Markdown")
sys.exit(1)
if __name__ == "__main__":
main()