summary refs log tree commit diff stats
path: root/classification/tools/analyze_results.py
diff options
context:
space:
mode:
authorChristian Krinitsin <mail@krinitsin.com>2025-07-04 19:54:17 +0200
committerChristian Krinitsin <mail@krinitsin.com>2025-07-04 19:54:17 +0200
commit55df9e6905dc57854bea8e34d1e71ea383eb0352 (patch)
treebd003cabebf496f923edc4df1eacf2c84d3f6b61 /classification/tools/analyze_results.py
parent4c7f62574f2e257741bc05bd3d7e5ec460ecf316 (diff)
downloadqemu-analysis-55df9e6905dc57854bea8e34d1e71ea383eb0352.tar.gz
qemu-analysis-55df9e6905dc57854bea8e34d1e71ea383eb0352.zip
analyze_results: add option to extract semantic bugs from classified category
Diffstat (limited to 'classification/tools/analyze_results.py')
-rwxr-xr-xclassification/tools/analyze_results.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/classification/tools/analyze_results.py b/classification/tools/analyze_results.py
index 663c1f559..f7429cf0e 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: