-
Notifications
You must be signed in to change notification settings - Fork 1
/
stark-multiresult.py
executable file
·37 lines (29 loc) · 1.1 KB
/
stark-multiresult.py
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
import sys
import time
from pathlib import Path
import stark
from stark.stark import read_settings, parse_args
import logging
logger = logging.getLogger('stark')
def main():
args = parse_args(sys.argv[1:])
settings = read_settings(args.config_file, args)
input_path = Path(settings['input_path'])
output_path_parts = Path(settings['output']).parts
for path in sorted(input_path.rglob('*.conllu')):
# create path to actual location
relative_path_parts = path.parts[len(input_path.parts):]
output_path = Path(*output_path_parts, *relative_path_parts)
output_path.parent.mkdir(parents=True, exist_ok=True)
if not output_path.exists():
logger.info(f'Processing file at: {path}')
settings['input_path'] = str(path)
settings['output'] = str(output_path)
stark.run(settings)
else:
logger.info(f'Already processed, skipping: {path}')
if __name__ == "__main__":
start_time = time.time()
main()
logger.info("Total:")
logger.info("--- %s seconds ---" % (time.time() - start_time))