2021-03-15 14:11:28 +00:00
|
|
|
import argparse
|
|
|
|
|
2021-03-18 12:48:14 +00:00
|
|
|
from structure_assignment.pipeline import Runner
|
2021-03-15 14:11:28 +00:00
|
|
|
|
2022-07-29 17:42:02 +00:00
|
|
|
classla_directory = '../resources/classla'
|
|
|
|
wani_file_name = '../resources/wani.py' # TODO: remove once luscenje_struktur incorporates wani in package
|
2021-03-15 14:11:28 +00:00
|
|
|
|
|
|
|
if (__name__ == '__main__'):
|
|
|
|
|
|
|
|
arg_parser = argparse.ArgumentParser(description='Run part or all of structure pipeline.')
|
2021-03-25 15:27:40 +00:00
|
|
|
arg_parser.add_argument('-mode', type=str, help='Mode')
|
2021-03-15 14:11:28 +00:00
|
|
|
arg_parser.add_argument('-infile', type=str, help='Input file')
|
|
|
|
arg_parser.add_argument('-outfile', type=str, help='Output file')
|
2021-06-29 19:00:27 +00:00
|
|
|
arg_parser.add_argument('-instructs', type=str, help='Input structure file')
|
|
|
|
arg_parser.add_argument('-outstructs', type=str, help='Output structure file')
|
2021-03-15 14:11:28 +00:00
|
|
|
arguments = arg_parser.parse_args()
|
|
|
|
|
2021-03-25 15:27:40 +00:00
|
|
|
mode = arguments.mode
|
2021-03-15 14:11:28 +00:00
|
|
|
input_file_name = arguments.infile
|
|
|
|
output_file_name = arguments.outfile
|
2021-06-29 19:00:27 +00:00
|
|
|
input_structure_file_name = arguments.instructs
|
|
|
|
output_structure_file_name = arguments.outstructs
|
2021-03-15 14:11:28 +00:00
|
|
|
|
2021-03-25 15:27:40 +00:00
|
|
|
nlp_needed = mode in {'strings_to_parse', 'strings_to_dictionary', 'all'}
|
2022-08-03 06:41:07 +00:00
|
|
|
runner = Runner(nlp_needed, classla_directory, wani_file_name)
|
2021-03-25 15:27:40 +00:00
|
|
|
if (mode == 'strings_to_parse'):
|
2021-03-18 12:48:14 +00:00
|
|
|
runner.strings_to_parse(input_file_name, output_file_name)
|
2021-03-25 15:27:40 +00:00
|
|
|
elif (mode == 'strings_to_dictionary'):
|
2021-06-29 19:00:27 +00:00
|
|
|
runner.strings_to_dictionary(input_file_name, output_file_name, input_structure_file_name, output_structure_file_name)
|
2021-03-25 15:27:40 +00:00
|
|
|
elif (mode == 'parse_to_dictionary'):
|
2021-06-29 19:00:27 +00:00
|
|
|
runner.parse_to_dictionary(input_file_name, output_file_name, input_structure_file_name, output_structure_file_name)
|
2021-03-25 15:27:40 +00:00
|
|
|
elif (mode == 'validate_structures'):
|
2021-03-18 12:48:14 +00:00
|
|
|
runner.validate_structures(input_file_name)
|
2021-03-25 15:27:40 +00:00
|
|
|
elif (mode == 'validate_dictionary'):
|
2021-03-18 12:48:14 +00:00
|
|
|
runner.validate_dictionary(input_file_name)
|
2021-03-25 15:27:40 +00:00
|
|
|
elif (mode == 'all'):
|
2021-06-29 19:00:27 +00:00
|
|
|
runner.run_all(input_file_name, output_file_name, input_structure_file_name, output_structure_file_name)
|