专名本土化(信达雅):冻结译名表 + 渲染层,并修掉校验器的正则盲点
- 新增 dfannals/glossary.py(译名表)与 dfannals/localize.py(渲染层) 人名=音译+绰号意译(Ral Fastenhatchets→拉尔·缚斧、朗古德·商熊「剖胎之寒」), 地名整体意译(Fordedwinds→涉风渡、The Volcano Of Ravens→渡鸦火山) - 生成链路本土化:素材渲染、人物表、扩写白名单全部走译名;已有产物做确定性替换 - 修复 factcheck 的 \b 盲点:Unicode 下汉字也算词字符,紧贴汉字的英文名不被检查 (曾因此漏掉编造专名)。修好后抓出并定点修掉长版第 1 集的 2 处编造 - 修正 title_form 大小写(YETI→Yeti),此前 Yeti/Goblin 一直漏译 - 新增 tests/test_localize.py(13 项回归)
This commit is contained in:
+6
-4
@@ -18,7 +18,7 @@ from collections import Counter
|
||||
from dataclasses import replace
|
||||
from pathlib import Path
|
||||
|
||||
from dfannals import deslop, volume
|
||||
from dfannals import deslop, localize, volume
|
||||
from dfannals import episodes as ep_mod
|
||||
from dfannals.chronicle import cjk_length
|
||||
from dfannals.config import (
|
||||
@@ -100,14 +100,16 @@ def allowed_names(world: World, thread: Thread, episode: ep_mod.Episode) -> list
|
||||
names.add(name)
|
||||
figure = world.figures.get(fid)
|
||||
if figure and figure.race:
|
||||
names.add(figure.race)
|
||||
names.add(_title_form(figure.race))
|
||||
# 种族值也要给中文:模型引到雪人、鹰人这类词时不能写成新角色
|
||||
names.add(localize.translate_race(figure.race))
|
||||
for event in episode.events:
|
||||
for ref in world.render_refs(event):
|
||||
value = ref.partition("=")[2].strip()
|
||||
if value:
|
||||
names.add(value)
|
||||
return sorted(n for n in names if n)
|
||||
# 全部过一遍译名表:白名单里必须是正文里真正会出现的写法
|
||||
translator = localize.for_world(world)
|
||||
return sorted({tr for tr in (translator.render(n).strip() for n in names) if tr})
|
||||
|
||||
|
||||
def chunk_messages(
|
||||
|
||||
Reference in New Issue
Block a user