| from response import TurboResponser | |
| import json | |
| def write_json_to_file(data, filepath): | |
| with open(filepath, 'w', encoding='utf-8') as f: | |
| json.dump(data, f, ensure_ascii=False, indent=4) | |
| import re | |
| def read_json(file_path): | |
| with open(file_path, "r", encoding="utf-8") as f: | |
| data = json.load(f) | |
| return data | |
| import datetime | |
| def write_log(message: str, log_file: str = "log-lcb.txt"): | |
| """ | |
| Append a timestamped log message to a log file. | |
| Args: | |
| message (str): The message to log. | |
| log_file (str): The path to the log file (default is 'log.txt'). | |
| Returns: | |
| None | |
| """ | |
| timestamp = datetime.datetime.now().strftime("[%Y-%m-%d %H:%M:%S]") | |
| with open(log_file, "w", encoding="utf-8") as f: | |
| f.write(f"{message}\n") | |
| # data_en = read_json("/home/i-luoxianzhen/data/TestCase-Gen/data/Ours/EN_section-6.json") | |
| # for item in data_en: | |
| # write_log(item['query'], f"/home/i-luoxianzhen/data/txt_check/CN-5/{item['tcb_id']}.txt") | |
| # if 'query_en' in item.keys(): | |
| # write_log(item['query_en'], f"/home/i-luoxianzhen/data/txt_check/EN-5/{item['tcb_id']}.txt") | |
| data_en = read_json("/home/i-luoxianzhen/data/TestCase-Gen/data/Ours/EN_section-2.json") | |
| import os | |
| import json | |
| def read_log(file_path): | |
| if os.path.exists(file_path): | |
| with open(file_path, 'r', encoding='utf-8') as f: | |
| return f.read() | |
| return None | |
| cn_folder = "/home/i-luoxianzhen/data/txt_check/CN/" | |
| en_folder = "/home/i-luoxianzhen/data/txt_check/EN/" | |
| for item in data_en: | |
| cn_file = read_log(f'{cn_folder}/{item["tcb_id"]}.txt') | |
| item['query'] = cn_file | |
| en_file = read_log(f'{en_folder}/{item["tcb_id"]}.txt') | |
| item['query_en'] = en_file | |
| write_json_to_file(data_en, '/home/i-luoxianzhen/data/TestCase-Gen/data/Ours/EN_section-2_checked.json') | |
Xet Storage Details
- Size:
- 1.84 kB
- Xet hash:
- 306f24e0a181bfd8d013eecf5235708d8a2246074d1d96539cfd17cf0116828d
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.