- Refactor codebase into src/ (preprocessing, translation, assembly) - Add pipeline/ scripts for individual stages - Externalize configuration to config/config.yaml - Fix Cover Image preservation - Update documentation and manuals
40 lines
1.5 KiB
Python
40 lines
1.5 KiB
Python
#!/usr/bin/env python3
|
|
"""模拟翻译流程,检查 _build_prompt 使用的数据"""
|
|
import sys
|
|
sys.path.insert(0, '.')
|
|
|
|
from src.manifest_manager import ManifestManager
|
|
from src.text_processor import TextProcessor
|
|
|
|
# 加载 manifest
|
|
manifest = ManifestManager("cache/manifests/Empire of AI Dreams and Nightmares in Sam Altmans OpenAI (Karen Hao)_chinese_manifest.json")
|
|
manifest.load()
|
|
|
|
# 创建 chunks (模拟 create_chunks_from_manifest)
|
|
processor = TextProcessor({})
|
|
chunks = processor.create_chunks_from_manifest(manifest, mode="chinese")
|
|
|
|
print(f"Total chunks: {len(chunks)}")
|
|
|
|
if chunks:
|
|
# 取第一个 chunk 的前几个 item
|
|
first_chunk = chunks[0]
|
|
print(f"First chunk has {len(first_chunk)} items")
|
|
|
|
for item in first_chunk[:5]:
|
|
print(f"\n=== ITEM {item.global_id} ===")
|
|
print(f" type(item): {type(item)}")
|
|
print(f" clean_text: '{item.clean_text[:50]}...'")
|
|
print(f" text_with_placeholders: '{item.text_with_placeholders[:50] if item.text_with_placeholders else 'EMPTY'}...'")
|
|
print(f" has φ in twp: {'φ' in (item.text_with_placeholders or '')}")
|
|
print(f" placeholder_map: {item.placeholder_map}")
|
|
|
|
# 模拟 _build_prompt 的逻辑
|
|
if item.text_with_placeholders:
|
|
text = item.text_with_placeholders
|
|
else:
|
|
text = item.clean_text
|
|
prompt_line = f"{item.global_id} [BODY] {text}"
|
|
print(f" -> Will send to LLM: '{prompt_line[:80]}...'")
|
|
print(f" -> Prompt contains φ: {'φ' in prompt_line}")
|