| name | wittsrc-link |
| version | 1.0.0 |
| description | 零 LLM 抽取 Wittgenstein 文本中的实体引用,生成 typed links 构建知识图谱。
通过正则匹配手稿编号、人名、哲学概念,生成 cites/evolves_to/contradicts/influenced_by 关系。
|
| triggers | ["抽取链接","auto-link","extract links","手稿引用关系","生成知识图谱","build graph"] |
| tools | ["wittsrc-auto-link"] |
| mutating | true |
wittsrc-link — 零 LLM 实体链接抽取
从 Brain Pages 中抽取实体引用,生成 typed links,不调用任何 LLM。
抽取范围
手稿编号正则
const MS_PATTERN = /Ms-(\d+[a-z]?)/g;
const TS_PATTERN = /Ts-(\d+[a-z]?)/g;
const PI_PATTERN = /PI §(\d+)/g;
const PR_PATTERN = /PR ([IVX]+)/g;
const ZETTEL_PATTERN = /Zettel §(\d+)/g;
const OC_PATTERN = /OC §(\d+)/g;
const BB_PATTERN = /BB §(\d+)/g;
const COMPOUND_PATTERN = /Ms-(\d+)[a-z]?[-–]Ts-(\d+)/g;
人名正则
const PHILOSOPHER_PATTERN = /\b(Wittgenstein|Russell|Moore|Ramsey|Frege|
Anscombe|von Wright|Pitcher|Moore|G.E. Moore|Bertrand Russell|
Frank Ramsey|Paul Engelmann|Maurice Drury|Theodore Redpath|
Yorick|Ramblings|F.p|Rawidowicz)\b/gi;
哲学概念正则
const CONCEPT_PATTERN = /\b(language-game|language games|private language|
family resemblance|family-similarity|rule-following|form of life|
picture theory|logical atomism|ethicism|ceremony|ceremonial|
aspect perception|philosophical grammar|perspective|definite description|
proposition|atomic proposition|tautology|contradiction|
nonsense|show|say|world|thought|facts|pictures)\b/gi;
链接类型推断
根据上下文模式推断关系类型:
type LinkType = 'cites' | 'evolves_to' | 'contradicts' | 'influenced_by' | 'defines' | 'revisits';
const PATTERN_MAP: Array<{
pattern: RegExp;
type: LinkType;
direction: 'forward' | 'backward';
}> = [
{ pattern: /worked out (?:in|below|here)/i, type: 'evolves_to', direction: 'forward' },
{ pattern: /this (?:will|can) be (?:found|seen|worked out)/i, type: 'evolves_to', direction: 'forward' },
{ pattern: /cf\.?\s+(Ms|Ts|PI|PR)/i, type: 'cites', direction: 'forward' },
{ pattern: /see (?:also\s+)?(Ms|Ts|PI|PR)/i, type: 'cites', direction: 'forward' },
{ pattern: /contrary (?:to|in) (PI|Ms|Ts|§)/i, type: 'contradicts', direction: 'forward' },
{ pattern: /(Ms|Ts)-(\d+).*?(contradicts?|opposed|against)/i, type: 'contradicts', direction: 'forward' },
{ pattern: /(Ms|Ts)-(\d+) is (?:superior|inferior) (?:to|in)/i, type: 'evolves_to', direction: 'forward' },
{ pattern: /(?:revised|rewritten|developed) in (Ms|Ts|PI)/i, type: 'evolves_to', direction: 'forward' },
{ pattern: /(?:influenced|shaped) by (Russell|Ramsey|Frege|Moore)/i, type: 'influenced_by', direction: 'forward' },
{ pattern: /Ramsey'?['']s (?:critique|criticism|notes)/i, type: 'cites', direction: 'forward' },
{ pattern: /the definition of (\w+)/i, type: 'defines', direction: 'forward' },
{ pattern: /revisits? (?:the (?:question|point|issue) of)/i, type: 'revisits', direction: 'forward' },
{ pattern: /in (PI §\d+|PR [IVX]+|Ms-\d+), we find/i, type: 'defines', direction: 'forward' },
];
输出格式
interface ExtractedLink {
sourceSlug: string;
targetSlug: string;
type: LinkType;
anchorText: string;
context: string;
confidence: number;
deterministic: boolean;
}
写入 brain/.links/ 目录:
corpus/wittgenstein/brain/.links/
links-2026-04-20.json (每次抽取的结果)
graph.json (合并后的图结构)
执行命令
bun run scripts/wittsrc-auto-link.ts \
--source corpus/wittgenstein/brain/works/ \
--output corpus/wittgenstein/brain/.links/
bun run scripts/wittsrc-auto-link.ts \
--source corpus/wittgenstein/brain/ \
--since 2026-04-19
bun run scripts/wittsrc-auto-link.ts \
--source corpus/wittgenstein/brain/ \
--dry-run
图结构
抽取结果合并为 JSON 图格式:
{
"nodes": [
{ "slug": "work-ms-114", "type": "work", "label": "Ms-114", "period": [1912, 1916] },
{ "slug": "work-ts-207", "type": "work", "label": "Ts-207", "period": [1929, 1931] },
{ "slug": "concept-language-game", "type": "concept", "label": "Language Game" }
],
"edges": [
{ "from": "work-ms-114", "to": "work-ts-207", "type": "evolves_to", "confidence": 0.85 },
{ "from": "work-ts-207", "to": "concept-language-game", "type": "defines", "confidence": 0.92 }
],
"meta": {
"extractedAt": "2026-04-20",
"totalNodes": 162,
"totalEdges": 847,
"avgConfidence": 0.78
}
}
防呆检查
反模式
- 不要在没有确认目标存在的情况下添加
evolves_to 链接
- 不要把
contradicts 误判为 cites("cf." 不等于"矛盾")
- 不要对代码块内容执行正则(手稿中有伪代码示例)