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
|
|
|
|
|
|
|
resource_directory = '../resources'
|
|
|
|
|
|
|
|
if (__name__ == '__main__'):
|
|
|
|
|
|
|
|
arg_parser = argparse.ArgumentParser(description='Run part or all of structure pipeline.')
|
|
|
|
arg_parser.add_argument('-part', type=str, help='Part name')
|
|
|
|
arg_parser.add_argument('-infile', type=str, help='Input file')
|
|
|
|
arg_parser.add_argument('-outfile', type=str, help='Output file')
|
|
|
|
arg_parser.add_argument('-structures', type=str, help='Updated structure file')
|
|
|
|
arguments = arg_parser.parse_args()
|
|
|
|
|
|
|
|
part_name = arguments.part
|
|
|
|
input_file_name = arguments.infile
|
|
|
|
output_file_name = arguments.outfile
|
|
|
|
structure_file_name = arguments.structures
|
|
|
|
|
2021-03-18 12:48:14 +00:00
|
|
|
nlp_needed = part_name in {'strings_to_parse', 'strings_to_dictionary', 'all'}
|
|
|
|
runner = Runner(resource_directory, nlp_needed)
|
2021-03-15 14:11:28 +00:00
|
|
|
if (part_name == 'strings_to_parse'):
|
2021-03-18 12:48:14 +00:00
|
|
|
runner.strings_to_parse(input_file_name, output_file_name)
|
2021-03-15 14:11:28 +00:00
|
|
|
elif (part_name == 'strings_to_dictionary'):
|
2021-03-18 12:48:14 +00:00
|
|
|
runner.strings_to_dictionary(input_file_name, output_file_name, structure_file_name)
|
2021-03-15 14:11:28 +00:00
|
|
|
elif (part_name == 'parse_to_dictionary'):
|
2021-03-18 12:48:14 +00:00
|
|
|
runner.parse_to_dictionary(input_file_name, output_file_name, structure_file_name)
|
2021-03-15 14:11:28 +00:00
|
|
|
elif (part_name == 'validate_structures'):
|
2021-03-18 12:48:14 +00:00
|
|
|
runner.validate_structures(input_file_name)
|
2021-03-15 14:11:28 +00:00
|
|
|
elif (part_name == 'validate_dictionary'):
|
2021-03-18 12:48:14 +00:00
|
|
|
runner.validate_dictionary(input_file_name)
|
2021-03-15 14:11:28 +00:00
|
|
|
elif (part_name == 'all'):
|
2021-03-18 12:48:14 +00:00
|
|
|
runner.run_all(input_file_name, output_file_name, nlp, structure_file_name)
|