Files
llm_wiki/wiki/人物Wiki文件生成规范.md

419 lines
11 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
categories:
- '[[LLM Wiki]]'
- '[[Documentation]]'
type: reference
tags:
- wiki
- documentation
created: 2026-04-14
source: '[[人物Wiki文件生成规范]]'
---
# 人物Wiki文件生成规范
> 本规范定义人物类Wiki笔记的创建标准,包括模板选择、frontmatter规范、Wikipedia URL生成规则、Base集成等。
## 一、模板选择规则
说明4个人物模板的适用场景:
| 模板 | 适用场景 | 典型人物 |
|
------|
----------|----------|
| **Author Template** | 以文字创作为主的人物 | 作家、学者、记者、评论家、编剧 |
| **People Template** | 通用人物(未特定为作者/演员/导演) | 历史人物、政治人物、军事人物、普通公众人物 |
| **Actors Template** | 以表演为职业的人物 | 电影演员、电视剧演员、话剧演员、艺人 |
| **Director Template** | 以导演/制片为职业的人物 | 电影导演、电视剧导演、制片人、编剧(侧重导演身份时) |
**选择原则**
- 一个人物可能符合多个模板,选择其**最知名的身份**
- 例如:张艺谋既是导演也是摄影师,优先使用Director Template
- 例如:鲁迅既是作家也是思想家,优先使用Author Template
---
## 二、Frontmatter规范
### 2.1 统一格式
所有人物模板categories统一:
```yaml
categories:
- "[[LLM Wiki]]"
- "[[People]]"
```
### 2.2 Type字段设计
| 模板 | Type值 | 说明 |
|------|---------|------|
| Author Template | `type:\n - "People"\n - "Author"` | 主类型+作者角色 |
| People Template | `type:\n - "People"` | 通用人物(可扩展) |
| Actors Template | `type:\n - "People"\n - "Actors"` | 主类型+演员角色 |
| Director Template | `type:\n - "People"\n - "Director"` | 主类型+导演角色 |
⚠️ **格式规则**
- type值使用双引号:`"People"`, `"Author"`
- type使用YAML列表格式,每行一个值
- type值**不能**使用wikilink格式(即不能用`[[People]]`
### 2.3 Tags规范
使用`person/`前缀的层级标签:
| Tag前缀 | 说明 | 示例 |
|---------|------|------|
| `person/author` | 作者、作家 | person/author |
| `person/actor` | 演员、艺人 | person/actor |
| `person/director` | 导演 | person/director |
| `person/historical` | 历史人物 | person/historical |
| `person/politics` | 政治人物 | person/politics |
| `person/scholar` | 学者 | person/scholar |
| `person/military` | 军事人物 | person/military |
| `person/education` | 教育界人士 | person/education |
**使用规则**
- 至少包含一个`person/xxx`标签
- 可同时使用多个标签(如`person/author` + `person/historical`
---
## 三、Wikipedia URL生成规则
### 3.1 基础信息
- **Kiwix服务器URL**`https://kiwix.haiguang.xyz:14004/viewer#wikipedia_zh_all_maxi_2025-09/`
- **本地数据文件**`D:\BaiduNetdiskDownload\wikipedia_zh_all_maxi_2025-09.zim`
- **编码要求**:中文需进行URL编码(UTF-8 percent encoding
### 3.2 URL编码示例
| 人物名 | URL编码 | 说明 |
|--------|----------|------|
| 李白 | `%E6%9D%8E%E7%99%BD` | 逐字符编码 |
| 张浩 | `%E5%BC%A0%E6%B5%A9` | 逐字符编码 |
| 王志纲 | `%E7%8E%8B%E5%BF%97%E7%BA%B2` | 逐字符编码 |
| Andrej Karpathy | `Andrej%20Karpathy` | 空格编码为`%20` |
### 3.3 完整URL示例
```
# 李白
https://kiwix.haiguang.xyz:14004/viewer#wikipedia_zh_all_maxi_2025-09/%E6%9D%8E%E7%99%BD
# 张浩
https://kiwix.haiguang.xyz:14004/viewer#wikipedia_zh_all_maxi_2025-09/%E5%BC%A0%E6%B5%A9
# 王志纲
https://kiwix.haiguang.xyz:14004/viewer#wikipedia_zh_all_maxi_2025-09/%E7%8E%8B%E5%BF%97%E7%BA%B2
# Andrej Karpathy
https://kiwix.haiguang.xyz:14004/viewer#wikipedia_zh_all_maxi_2025-09/Andrej%20Karpathy
```
### 3.4 URL编码方法
**方法1:在线工具**
- 使用<https://www.urlencoder.org/>
- 输入中文,自动生成编码
**方法2Python脚本**
```python
from urllib.parse import quote
quote("李白") # 输出: %E6%9D%8E%E7%99%BD
quote("张浩") # 输出: %E5%BC%A0%E6%B5%A9
```
**方法3:浏览器**
- 在地址栏输入中文,复制自动编码的URL
**方法4JavaScript**
```javascript
encodeURIComponent("李白") // 输出: %E6%9D%8E%E7%99%BD
```
---
## 四、Base Embed规则
| 模板 | Embed代码 | 显示内容 |
|------|-----------|----------|
| Author Template | `![[Books.base#Author]]` | 显示该作者的书籍列表 |
| Actors Template | `![[Movies.base#Actor]]` | 显示该演员参演的电影列表 |
| Director Template | `![[Movies.base#Director]]` | 显示该导演执导的电影列表 |
| People Template | 根据角色添加 | 如果是作者则添加Books embed,如果是演员/导演则添加Movies embed |
**Embed位置**:放在文档底部,"## 相关作品"或"## 作品列表"章节下。
---
## 五、照片嵌入规则
- **照片路径**`Attachments/people/人物名.jpg`
- **嵌入语法**`![[Attachments/people/人物名.jpg]]`
- **验证建议**:使用多模态大模型验证照片与人物的匹配性
### 5.1 照片自动获取方案
**可复用脚本**`scripts/fetch_wikipedia_photo.py`
```bash
# 获取单个人物照片
python scripts/fetch_wikipedia_photo.py 张艺谋
# 指定语言
python scripts/fetch_wikipedia_photo.py "Alan Turing" --lang en
# 指定缩略图宽度
python scripts/fetch_wikipedia_photo.py 张艺谋 --width 600
# 批量获取
python scripts/fetch_wikipedia_photo.py 张艺谋 巩俐 章子怡 --batch
# 从文件读取人物列表
python scripts/fetch_wikipedia_photo.py --from-file people_list.txt
```
**原理:Wikipedia PageImages API**
```
https://{lang}.wikipedia.org/w/api.php?action=query&prop=pageimages&format=json&piprop=original&titles={人物名}
```
**手动获取流程**(网络受限时):
1. 通过 Exa 爬取 Wikipedia API JSON
2. 从返回 JSON 中提取 `original.source` 字段(图片URL
3. 使用 Wikimedia 缩略图 URL 获取合适尺寸:在文件名前加 `/400px-`
4. 下载到 `Attachments/people/人物名.jpg`
---
## 六、信息自动填充工作流
### 6.1 从 Wikipedia 自动提取 Frontmatter 字段
**数据源**:通过 Exa 爬取中文 Wikipedia 页面(`https://zh.wikipedia.org/wiki/{人物名}`
**提取规则**(从 Wikipedia infobox 提取):
| Frontmatter 字段 | Wikipedia infobox 字段 | 提取说明 |
|------------------|----------------------|----------|
| `birthday` | 出生 | 提取 YYYY-MM-DD 格式日期 |
| `death` | 逝世 | 提取日期,无则留空 |
| `nationality` | 国籍 | 默认"中国" |
| `origin` | 出生/籍贯 | 提取省市区 |
| `aliases` | 本名/别名 | 列表格式,加英文名 |
| `source` | — | 设为 `"[[Wikipedia]]"` |
**工作流**
1. 使用 Exa 爬取 Wikipedia 页面内容
2. 提取 infobox 中的结构化数据
3. 按模板格式填充 frontmatter
4. 提取生平、作品、荣誉等章节内容
5. 生成完整的 wiki 笔记
**示例**:张艺谋的 Wikipedia infobox 提取结果:
```yaml
birthday: 1950-04-02
nationality: 中国
origin: 陕西省西安市
aliases:
- 张诒谋
- 老谋
- Yimou Zhang
```
---
## 七、Base 视图别名匹配
### 7.1 问题说明
当 Base 视图嵌入人物笔记时,`this` 指向嵌入文件(File 对象)。电影/书籍笔记的 `director`/`author` 字段可能是以下任一格式:
| 字段格式 | 示例 | 匹配难度 |
|----------|------|----------|
| 纯文本 | `director: 张艺谋` | `list.contains(this)` 可匹配 |
| 扩展名称 | `director: "张艺谋 Yimou Zhang"` | 需要子串匹配 |
| Wikilink | `director: "[[张艺谋]]"` | 需要 `file.hasLink()` 匹配 |
| 列表 | `director: ["张艺谋", "其他"]` | `list.contains(this)` 可匹配 |
`list.contains(this)` 只匹配精确值,`string.containsAny(this.aliases)` 可能无法正确展开 List 参数。
### 7.2 解决方案
所有涉及人物匹配的 Base 视图统一使用三重 `or` 条件:
```yaml
# Director 视图
filters:
or:
- list(director).contains(this) # 精确匹配(纯文本/列表)
- director.contains(this.file.name) # 子串匹配(扩展名称)
- file.hasLink(this.file) # Wikilink 匹配
# Actor 视图
filters:
or:
- list(cast).contains(this)
- cast.contains(this.file.name)
- file.hasLink(this.file)
# Author 视图
filters:
or:
- list(author).contains(this)
- author.contains(this.file.file.name)
- file.hasLink(this.file)
```
**三个条件各自覆盖**
| 条件 | 覆盖场景 | 原理 |
|------|----------|------|
| `list(x).contains(this)` | `director: 张艺谋``director: ["张艺谋"]` | File 对象与列表元素匹配 |
| `x.contains(this.file.name)` | `director: "张艺谋 Yimou Zhang"` | 文件名作为子串在字段值中查找 |
| `file.hasLink(this.file)` | `director: "[[张艺谋]]"` | 检查笔记是否包含指向人物文件的链接 |
---
## 八、验证清单
创建人物笔记后,请逐项检查:
- [ ] frontmatter包含`[[LLM Wiki]]``[[People]]`categories
- [ ] type字段格式正确(字符串、引号包裹、列表格式)
- [ ] type值不使用wikilink格式
- [ ] tags包含至少一个`person/xxx`前缀标签
- [ ] source字段指向raw来源(单行字符串、wikilink格式)
- [ ] 文档底部包含相应的Base embedBooks/Movies
- [ ] 照片路径正确:`Attachments/people/人物名.jpg`
- [ ] Wikipedia URL编码正确(如使用)
---
## 九、参考实例
| 文件 | 模板类型 | 特点 |
|------|----------|------|
| `wiki/张艺谋.md` | Director Template | ✅ 完整示例(Wikipedia数据填充、照片、Base embed |
| `wiki/王志纲.md` | Author Template | 现代学者、作家 |
| `wiki/张浩.md` | People Template | 历史人物 |
| `wiki/李白.md` | People Template | 历史人物(诗人) |
---
## 十、快速参考
### 完整frontmatter示例
---
## 规范文档
详见 [[人物Wiki文件生成规范]]
**Author Template**
```yaml
---
categories:
- "[[LLM Wiki]]"
- "[[People]]"
tags:
- wiki
- people
- person/author
type: entity
- "People"
- "Author"
source: "[[来源]]"
created: 2026-04-14
last: 2026-04-14
birthday:
death:
nationality: 中国
origin:
aliases: []
---
```
**Actors Template**
```yaml
---
categories:
- "[[LLM Wiki]]"
- "[[People]]"
tags:
- wiki
- people
- person/actor
type: entity
- "People"
- "Actors"
source: "[[来源]]"
created: 2026-04-14
last: 2026-04-14
birthday:
death:
nationality: 中国
origin:
aliases: []
---
```
**Director Template**
```yaml
---
categories:
- "[[LLM Wiki]]"
- "[[People]]"
tags:
- wiki
- people
- person/director
type: entity
- "People"
- "Director"
source: "[[来源]]"
created: 2026-04-14
last: 2026-04-14
birthday:
death:
nationality: 中国
origin:
aliases: []
---
```
**People Template**
```yaml
---
categories:
- "[[LLM Wiki]]"
- "[[People]]"
tags:
- wiki
- people
- person/historical
type: entity
- "People"
source: "[[来源]]"
created: 2026-04-14
last: 2026-04-14
birthday:
death:
nationality: 中国
origin:
aliases: []
---
```
## 来源
> **溯源规则**:所有数字/百分比/具体结论必须标注 `[raw:{文件名}:{行号}]` 格式。
- [[人物Wiki文件生成规范]]