Delete utils/convert.py
Browse files- utils/convert.py +0 -27
utils/convert.py
DELETED
|
@@ -1,27 +0,0 @@
|
|
| 1 |
-
import json
|
| 2 |
-
def load_line_json_data(filename):
|
| 3 |
-
data = []
|
| 4 |
-
with open(filename, 'r', encoding='utf-8') as f:
|
| 5 |
-
for line in f.read().strip().split('\n'):
|
| 6 |
-
unit = json.loads(line)
|
| 7 |
-
data.append(unit)
|
| 8 |
-
return data
|
| 9 |
-
|
| 10 |
-
def save_file(data, path):
|
| 11 |
-
with open(path,'w',encoding='utf-8') as w:
|
| 12 |
-
for unit in data:
|
| 13 |
-
output = json.dumps(unit)
|
| 14 |
-
w.write(output + "\n")
|
| 15 |
-
w.close()
|
| 16 |
-
|
| 17 |
-
data = load_line_json_data('/home/xj/toolAugEnv/code/toolConstraint/data/query/zk.jsonl')
|
| 18 |
-
query_output = open('/home/xj/toolAugEnv/code/toolConstraint/data/api_request/zk_hard_regen.txt','r').read().strip().split('\n')
|
| 19 |
-
# assert len(data) == len(query_output)
|
| 20 |
-
|
| 21 |
-
for unit, output in zip(data[24:], query_output):
|
| 22 |
-
# unit['local_constraint']['transportation'] = None
|
| 23 |
-
unit['query'] = " ".join(x for x in output.split('\t')[1:])
|
| 24 |
-
# for unit in data:
|
| 25 |
-
# unit['local_constraint']['transportation'] = None
|
| 26 |
-
|
| 27 |
-
save_file(data,'/home/xj/toolAugEnv/code/toolConstraint/data/query/zk.jsonl')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|