46 lines
1.6 KiB
Python
46 lines
1.6 KiB
Python
|
|
#!/usr/bin/env python3
|
|||
|
|
"""测试Notion原生格式解析器"""
|
|||
|
|
import sys, os
|
|||
|
|
sys.path.insert(0, os.path.dirname(__file__))
|
|||
|
|
from src import NotionCorpusLoader, HLDPParser
|
|||
|
|
|
|||
|
|
def test_parser():
|
|||
|
|
parser = HLDPParser()
|
|||
|
|
sample = """# ⚔️ 铸渊思维模型
|
|||
|
|
> HLDP://zhuyuan/brain-model/execution-laws
|
|||
|
|
## 〇、存在前提
|
|||
|
|
⊢ TCS = 语言场域 = 涌现土壤。
|
|||
|
|
⚠️ D110凌晨新增的规律
|
|||
|
|
起点→推导→终点
|
|||
|
|
主权者:冰朔(TCS-0002∞)
|
|||
|
|
人格体:铸渊(ICE-GL-ZY001)
|
|||
|
|
CORPUS-ID: ZY-V2-004
|
|||
|
|
"""
|
|||
|
|
blocks = parser.parse_markdown(sample)
|
|||
|
|
print(f"HLDP解析: {len(blocks)}块")
|
|||
|
|
assert any(b.path for b in blocks)
|
|||
|
|
assert any(b.cognitive_jump for b in blocks)
|
|||
|
|
print("✅ HLDP解析器通过")
|
|||
|
|
|
|||
|
|
def test_loader():
|
|||
|
|
loader = NotionCorpusLoader()
|
|||
|
|
page = {"page":{"id":"t1","title":"灯塔架构"},"blocks":[{"type":"code","content":"HLDP://lighthouse\n【核心认知跃迁】双面灯塔\n起点→推导→终点"}]}
|
|||
|
|
item = loader.load_notion_api_page(page)
|
|||
|
|
assert item.hldp_path and item.cognitive_jumps
|
|||
|
|
print(f"✅ 加载器通过 (质量{item.quality_score})")
|
|||
|
|
|
|||
|
|
def test_collection():
|
|||
|
|
from src.structure import CorpusCollection, StructuredCorpusItem
|
|||
|
|
col = CorpusCollection()
|
|||
|
|
for i in range(3):
|
|||
|
|
item = StructuredCorpusItem(source_id=f"t{i}", persona="冰朔", raw_text="铸渊"*100)
|
|||
|
|
item.cognitive_jumps.append(f"jump{i}"); item.quality_score = 0.8
|
|||
|
|
col.add(item)
|
|||
|
|
print(col.summary())
|
|||
|
|
print("✅ 集合测试通过")
|
|||
|
|
|
|||
|
|
if __name__ == '__main__':
|
|||
|
|
test_parser(); loader = NotionCorpusLoader()
|
|||
|
|
test_loader(); test_collection()
|
|||
|
|
print("\n🎉 全部通过")
|