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.')
|
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'}
|
2021-03-18 12:48:14 +00:00
|
|
|
runner = Runner(resource_directory, nlp_needed)
|
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)
|