odt2tei.py
1.61 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
"Convert scanned ODT to TEI"
import argparse
import logging
from math import log
from odt2tei.converter import Converter
def parse_options():
parser = argparse.ArgumentParser(description="Convert ODT documents to PCC TEI")
parser.add_argument(
"-o",
"--output",
default="output",
metavar="<folder>",
help="folder to save data",
)
parser.add_argument(
"-d",
"--debug",
default="",
metavar="<folder>",
help="category to debug",
choices=[
"",
"lines",
"odt",
"spaceout",
"whitespace",
"punctuation",
"merge",
"illegible",
"speakers",
"comments",
"split",
],
)
parser.add_argument("-f", "--force", action="store_true", help="save invalid files")
parser.add_argument(
"-v", "--verbose", action="store_true", help="print correct files"
)
parser.add_argument(
"-s", "--stop-on-error", action="store_true", help="stop on error"
)
parser.add_argument("filename", nargs="+", help="folder or filename")
args = parser.parse_args()
if args.debug:
loglevel = logging.DEBUG
elif args.verbose:
loglevel = logging.INFO
else:
loglevel = logging.WARNING
logging.basicConfig(format="%(message)s", level=loglevel)
return args
def main():
"Main loop"
args = parse_options()
converter = Converter(args)
for filename in args.filename:
converter.convert(filename)
if __name__ == "__main__":
main()