22 lines
651 B
Python
22 lines
651 B
Python
|
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')
|