MCPcopy
hub / github.com/Turing-Project/WriteGPT / process

Method process

LanguageNetwork/BERT/utils/pyrouge.py:34–53  ·  view source on GitHub ↗

Apply function to all files in input_dir and save the resulting ouput files in output_dir.

(input_dir, output_dir, function)

Source from the content-addressed store, hash-verified

32
33 @staticmethod
34 def process(input_dir, output_dir, function):
35 """
36 Apply function to all files in input_dir and save the resulting ouput
37 files in output_dir.
38
39 """
40 if not os.path.exists(output_dir):
41 os.makedirs(output_dir)
42 logger = log.get_global_console_logger()
43 logger.info("Processing files in {}.".format(input_dir))
44 input_file_names = os.listdir(input_dir)
45 for input_file_name in input_file_names:
46 input_file = os.path.join(input_dir, input_file_name)
47 with codecs.open(input_file, "r", encoding="UTF-8") as f:
48 input_string = f.read()
49 output_string = function(input_string)
50 output_file = os.path.join(output_dir, input_file_name)
51 with codecs.open(output_file, "w", encoding="UTF-8") as f:
52 f.write(clean(output_string.lower()))
53 logger.info("Saved processed files to {}.".format(output_dir))
54
55
56class Rouge155(object):

Callers 1

Calls 2

writeMethod · 0.80
cleanFunction · 0.70

Tested by

no test coverage detected