MalGraph/samples/funCount.py

22 lines
651 B
Python
Raw Normal View History

2023-12-28 17:01:36 +08:00
import json
from tqdm import tqdm
if __name__ == '__main__':
file_name = './sample.jsonl'
fil = open(file_name, mode='r')
fun_name_dict = {}
for item in tqdm(fil):
item = json.loads(item)
item_fun_list = item['function_names']
for fun_name in item_fun_list:
if fun_name_dict.get(fun_name) is not None:
fun_name_dict[fun_name] += 1
else:
fun_name_dict[fun_name] = 1
with open('./res.jsonl','w') as file:
for key,value in fun_name_dict.items():
temp = {"f_name":key, "count":value}
file.write(json.dumps(temp) + '\n')