MCPcopy Create free account
hub / github.com/SmartFlowAI/EmoLLM / encode_raw_corpus

Function encode_raw_corpus

rag/src/util/encode.py:22–36  ·  view source on GitHub ↗
(file_path: str, store_path: str)

Source from the content-addressed store, hash-verified

20文本编码
21"""
22def 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"""

Callers

nothing calls this directly

Calls 2

load_embeddingFunction · 0.70
encodeMethod · 0.45

Tested by

no test coverage detected