概念
原文 + 白話 + 動態注釋查詢,是學者跑古典文獻最小工作流。
import requests
CHAPTERS = {
1: "道可道,非常道。名可名,非常名。無,名天地之始;有,名萬物之母。",
2: "天下皆知美之為美,斯惡已;皆知善之為善,斯不善已。故有無相生,難易相成。",
11: "三十輻共一轂,當其無,有車之用。",
33: "知人者智,自知者明。勝人者有力,自勝者強。",
81: "信言不美,美言不信。善者不辯,辯者不善。",
}
def fetch_commentary(chapter_num: int, original: str):
q = f"道德經 第{chapter_num}章 {original[:8]} 王弼 河上公"
res = requests.post(
"https://lius.cc/api/llm-rag",
json={"q": q, "n": 5, "types": ["scripture", "concept", "paper"]},
timeout=10,
)
res.raise_for_status()
return res.json().get("hits", [])
for num, text in CHAPTERS.items():
print(f"\n=== 第 {num} 章 ===")
print(f"原文:{text}")
hits = fetch_commentary(num, text)
for h in hits[:3]:
print(f" ▸ [{h['type']}] {h['name']} (score {h['score']})")