(file_path: str, store_path: str)
| 20 | 文本编码 |
| 21 | """ |
| 22 | def encode_raw_corpus(file_path: str, store_path: str) -> None: |
| 23 | emb = load_embedding() |
| 24 | with open(file_path, 'r', encoding='utf-8') as f: |
| 25 | read_lines = f.readlines() |
| 26 | |
| 27 | """ |
| 28 | 对文本分割(例如:按句子分割) |
| 29 | """ |
| 30 | lines = [] |
| 31 | # 分割好后的存入 lines 中 |
| 32 | |
| 33 | # 编码(转换为向量) |
| 34 | encoded_knowledge = emb.encode(lines) |
| 35 | with open(store_path, 'wb') as f: |
| 36 | pickle.dump(encoded_knowledge, f) |
| 37 | |
| 38 | |
| 39 | """ |
nothing calls this directly
no test coverage detected