From 55df9e6905dc57854bea8e34d1e71ea383eb0352 Mon Sep 17 00:00:00 2001 From: Christian Krinitsin Date: Fri, 4 Jul 2025 19:54:17 +0200 Subject: analyze_results: add option to extract semantic bugs from classified category --- classification/tools/analyze_results.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/classification/tools/analyze_results.py b/classification/tools/analyze_results.py index 663c1f55..f7429cf0 100755 --- a/classification/tools/analyze_results.py +++ b/classification/tools/analyze_results.py @@ -1,10 +1,11 @@ from argparse import ArgumentParser -from os import path, listdir +from os import path, listdir, makedirs parser = ArgumentParser() parser.add_argument('-b', '--bugs', required = True) parser.add_argument('-d', '--search_directory', required = True) +parser.add_argument('-o', '--output') args = parser.parse_args() @@ -27,6 +28,14 @@ def output_csv(dictionary, full_path): for key, value in dictionary.items(): file.write(f"{key}, {value}\n") +def duplicate_bug(file_path, category): + output_path = path.join(args.output, category) + makedirs(output_path, exist_ok = True) + with open(file_path, "r") as file: + text = file.read() + with open(path.join(output_path, path.basename(file_path)), "w") as file: + file.write(text) + def main(): result = {} mistranslation_bugs = list_files_recursive(args.bugs, True) @@ -36,6 +45,8 @@ def main(): for bug in bugs: if mistranslation_bug == path.basename(bug): category = path.basename(path.dirname(bug)) + if args.output: + duplicate_bug(bug, category) if category in result: result[category] += 1 else: -- cgit 1.4.1