-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalc_java.py
More file actions
39 lines (34 loc) · 1.37 KB
/
calc_java.py
File metadata and controls
39 lines (34 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import subprocess
import os, glob
import sys
def test(id, name, tag):
command = "cd evalrepair-java && bash test.sh " + str(id) + " " + name + " " + tag
print(command)
process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = process.communicate()
print("Standard Output:", stdout.decode())
print("Standard Error:", stderr.decode())
print(process.returncode)
return [process.returncode, str(stdout)]
ac = {}
ac5 = {}
ac1 = {}
bug = 0
ss = 0
for id in range(10):
directory_path = f"./evalrepair-java-res/{sys.argv[1]}/fixed{id}/"
if os.path.exists(directory_path) and os.path.isdir(directory_path):
for file_path in sorted(glob.glob(os.path.join(directory_path, '*.java')), reverse=False):
print(file_path)
name = file_path.split('/')[-1].split('.')[0]
if sys.argv[-1] == "rejudge":
ret, detail = test(id, name, sys.argv[1])
else:
ret = (int)(open(file_path + '.result', 'r').read())
if ret == 0:
ac[name] = ac.get(name, 0) + 1
if id < 5:
ac5[name] = ac5.get(name, 0) + 1
if id == 0:
ac1[name] = ac1.get(name, 0) + 1
print('TOP-10:', len(ac) / 163 * 100, 'TOP-5:', len(ac5) / 163 * 100, 'TOP-1:', len(ac1) / 163 * 100)