hsaest commited on
Commit
b323e1e
·
verified ·
1 Parent(s): 4775c44

Delete utils/budget_reset.py

Browse files
Files changed (1) hide show
  1. utils/budget_reset.py +0 -36
utils/budget_reset.py DELETED
@@ -1,36 +0,0 @@
1
- import json
2
- from evaluation.hardConstriant import get_total_cost
3
- from tqdm import tqdm
4
- import math
5
-
6
- def load_line_json_data(filename):
7
- data = []
8
- with open(filename, 'r', encoding='utf-8') as f:
9
- for line in f.read().strip().split('\n'):
10
- unit = json.loads(line)
11
- data.append(unit)
12
- return data
13
-
14
- def round_up_to_nearest_hundred(number):
15
- return math.ceil(number / 100) * 100
16
-
17
- if __name__ == '__main__':
18
- query = load_line_json_data('/home/xj/toolAugEnv/code/toolConstraint/data/query/all_reset_budget.jsonl')
19
- rewritten_query = open('/home/xj/toolAugEnv/code/toolConstraint/data/api_request/query_rewritten_reset_budget_gpt4.txt').readlines()
20
- assert len(rewritten_query) == len(query)
21
- for idx in tqdm(range(len(query))):
22
- # tested_data = json.load(open(f'/home/xj/toolAugEnv/code/toolConstraint/data/annotation/all/annotation_{idx+1}.json'))
23
- # query[idx]['reset_budget'] = round_up_to_nearest_hundred(get_total_cost(query[idx], tested_data))
24
- # print(query[idx])
25
- # break
26
- query[idx]['query'] = "".join(x for x in rewritten_query[idx].strip().split('\t')[1:])
27
- query[idx]['budget'] = query[idx]['reset_budget']
28
- query[idx].pop('reset_budget')
29
-
30
-
31
- with open('/home/xj/toolAugEnv/code/toolConstraint/data/query/all.jsonl', 'w') as f:
32
- for query_unit in query:
33
- # print(query)
34
- json.dump(query_unit, f)
35
- f.write('\n')
36
- f.close()