Redmine #1487: minor bugs and refactoring

This commit is contained in:
Cyprian Laskowski 2021-03-25 10:57:19 +01:00
parent 92fa061dfc
commit 51f5e14ee9
2 changed files with 8 additions and 14 deletions

View File

@ -26,18 +26,18 @@ class Runner:
NLP_CONFIG_MAP['dir'] = resource_directory + '/classla' NLP_CONFIG_MAP['dir'] = resource_directory + '/classla'
self.nlp = classla.Pipeline('sl', **NLP_CONFIG_MAP) self.nlp = classla.Pipeline('sl', **NLP_CONFIG_MAP)
def run_all(input_file_name, output_file_name, structure_file_name): def run_all(self, input_file_name, output_file_name, structure_file_name):
pipeline = Pipeline(self.resource_directory, self.nlp) pipeline = Pipeline(self.resource_directory, self.nlp)
pipeline.import_file(input_file_name, 'strings-list') pipeline.import_file(input_file_name, 'strings-list')
self._strings_to_parse_sequence(pipeline) self._strings_to_parse_sequence(pipeline)
self._parse_to_dictionary_sequence(pipeline) self._parse_to_dictionary_sequence(pipeline)
pipeline.export_file(output_file_name, 'dictionary') pipeline.do_validate_structures()
pipeline.export_file(structure_file_name, 'structures-new') pipeline.export_file(structure_file_name, 'structures-new')
self._validate_structures(structure_file_name) pipeline.do_validate_dictionary()
self._validate_dictionary(output_file_name) pipeline.export_file(output_file_name, 'dictionary')
pipeline.cleanup() pipeline.cleanup()
def strings_to_dictionary(input_file_name, output_file_name, structure_file_name): def strings_to_dictionary(self, input_file_name, output_file_name, structure_file_name):
pipeline = Pipeline(self.resource_directory, self.nlp) pipeline = Pipeline(self.resource_directory, self.nlp)
pipeline.import_file(input_file_name, 'strings-list') pipeline.import_file(input_file_name, 'strings-list')
self._strings_to_parse_sequence(pipeline) self._strings_to_parse_sequence(pipeline)
@ -64,13 +64,13 @@ class Runner:
def validate_structures(self, input_file_name): def validate_structures(self, input_file_name):
pipeline = Pipeline(self.resource_directory) pipeline = Pipeline(self.resource_directory)
pipeline.import_file(input_file_name, 'structures-new') pipeline.import_file(input_file_name, 'structures-new')
self._validate_structures_sequence(pipeline) pipeline.do_validate_structures()
pipeline.cleanup() pipeline.cleanup()
def validate_dictionary(self, input_file_name): def validate_dictionary(self, input_file_name):
pipeline = Pipeline(self.resource_directory) pipeline = Pipeline(self.resource_directory)
pipeline.import_file(input_file_name, 'dictionary') pipeline.import_file(input_file_name, 'dictionary')
self._validate_dictionary_sequence(pipeline) pipeline.do_validate_dictionary()
pipeline.cleanup() pipeline.cleanup()
def _strings_to_parse_sequence(self, pipeline): def _strings_to_parse_sequence(self, pipeline):
@ -92,12 +92,6 @@ class Runner:
pipeline.do_tei_to_dictionary_multiple() pipeline.do_tei_to_dictionary_multiple()
pipeline.do_merge_dictionaries() pipeline.do_merge_dictionaries()
def _validate_structures_sequence(self, pipeline):
pipeline.do_validate_structures()
def _validate_dictionary_sequence(self, pipeline):
pipeline.do_validate_dictionary()
class Pipeline: class Pipeline:

View File

@ -31,4 +31,4 @@ if (__name__ == '__main__'):
elif (part_name == 'validate_dictionary'): elif (part_name == 'validate_dictionary'):
runner.validate_dictionary(input_file_name) runner.validate_dictionary(input_file_name)
elif (part_name == 'all'): elif (part_name == 'all'):
runner.run_all(input_file_name, output_file_name, nlp, structure_file_name) runner.run_all(input_file_name, output_file_name, structure_file_name)