| import json | |
| import string | |
| def save_dict(file_path, data_dict, encoding='utf-8'): | |
| with open(file_path, "w", encoding=encoding) as f: | |
| json.dump(data_dict, f, ensure_ascii=False) | |
| def load_dict(file_path): | |
| with open(file_path, "r", encoding='utf-8') as f: | |
| data_dict = json.load(f) | |
| return data_dict | |
| def read_file(file_path): | |
| with open(file_path, "r", encoding="utf-8") as f: | |
| sentences = f.readlines() | |
| return sentences | |