feat: complete wikification of War Commander batch 1&2 and final grey dot cleanup
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
|
||||
raw_path = r'E:\Wiki\2nd\00_Raw'
|
||||
target_base = r'E:\Wiki\2nd\10_Wiki\Topics\Game Design'
|
||||
|
||||
if not os.path.exists(target_base):
|
||||
os.makedirs(target_base)
|
||||
|
||||
def sanitize_filename(filename):
|
||||
# Extract English name from parentheses if exists, else clean Korean
|
||||
match = re.search(r'\((.*?)\)', filename)
|
||||
if match:
|
||||
name = match.group(1)
|
||||
else:
|
||||
name = filename.replace('.md', '')
|
||||
|
||||
# Remove special chars, replace spaces with hyphens
|
||||
name = re.sub(r'[^\w\s-]', '', name)
|
||||
name = name.strip().replace(' ', '-')
|
||||
return name + '.md'
|
||||
|
||||
files = [f for f in os.listdir(raw_path) if f.endswith('.md')]
|
||||
|
||||
for f in files:
|
||||
src_path = os.path.join(raw_path, f)
|
||||
new_filename = sanitize_filename(f)
|
||||
dest_path = os.path.join(target_base, new_filename)
|
||||
|
||||
try:
|
||||
with open(src_path, 'r', encoding='utf-8', errors='ignore') as f_obj:
|
||||
content = f_obj.read()
|
||||
|
||||
# Extract title from first line if it's a header
|
||||
title_match = re.search(r'^#\s+\[\[(.*?)\]\]', content)
|
||||
if title_match:
|
||||
display_title = title_match.group(1)
|
||||
else:
|
||||
display_title = f.replace('.md', '')
|
||||
|
||||
# Build Wikified Content
|
||||
wikified = f"""---
|
||||
id: GAME-WC-{new_filename.split('.')[0].upper()}
|
||||
category: "10_Wiki/💡 Topics/Game Design"
|
||||
confidence_score: 1.0
|
||||
tags: [war-commander, game-mechanics, tactical-analysis]
|
||||
last_reinforced: 2026-04-27
|
||||
---
|
||||
|
||||
# [[{display_title}]]
|
||||
|
||||
"""
|
||||
# Reformat sections if they follow the draft pattern
|
||||
content = content.replace('## 📌 Brief Summary', '## 📌 한 줄 통찰 (The Karpathy Summary)')
|
||||
content = content.replace('## 📖 Core Content', '## 📖 구조화된 지식 (Synthesized Content)')
|
||||
content = content.replace('## 🔗 Knowledge Connections', '## 🔗 지식 연결 (Graph)')
|
||||
|
||||
# Add the rest of the content (skipping the original title if we already added one)
|
||||
body = re.sub(r'^#\s+\[\[.*?\]\]\s*', '', content, flags=re.MULTILINE)
|
||||
|
||||
# Ensure Contradictions header exists
|
||||
if '## ⚠️ 모순 및 업데이트' not in body:
|
||||
body = body.replace('## 🔗 지식 연결', '## ⚠️ 모순 및 업데이트 (Contradictions & RL Update)\n- 신규 지식 자산화 (2026-04-27).\n- War Commander 전투 생태계 데이터 통합.\n\n## 🔗 지식 연결')
|
||||
|
||||
wikified += body
|
||||
|
||||
with open(dest_path, 'w', encoding='utf-8') as f_obj:
|
||||
f_obj.write(wikified)
|
||||
|
||||
# Delete raw file
|
||||
os.remove(src_path)
|
||||
print(f"Wikified: {f} -> {new_filename}")
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error processing {f}: {e}")
|
||||
Reference in New Issue
Block a user