File size: 708 Bytes
db06ffa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""Parse a folder sequentially."""

from __future__ import annotations

import argparse
from pathlib import Path

from zsgdp import parse_document


def main() -> int:
    parser = argparse.ArgumentParser()
    parser.add_argument("input")
    parser.add_argument("output")
    args = parser.parse_args()

    input_dir = Path(args.input)
    output_dir = Path(args.output)
    output_dir.mkdir(parents=True, exist_ok=True)
    for path in sorted(item for item in input_dir.iterdir() if item.is_file()):
        parsed = parse_document(path, output_dir / path.stem)
        print(f"{path.name}: score={parsed.quality_report.score:.2f}")
    return 0


if __name__ == "__main__":
    raise SystemExit(main())