111 lines
3.6 KiB
Python
111 lines
3.6 KiB
Python
import os
|
|
import re
|
|
import uuid
|
|
import sys
|
|
from datetime import datetime
|
|
|
|
# UTF-8 출력 보정
|
|
if sys.stdout.encoding != 'utf-8':
|
|
import io
|
|
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
|
|
|
|
base_dir = r"e:\Wiki\2nd"
|
|
raw_dir = os.path.join(base_dir, "00_Raw", "2026-04-20")
|
|
wiki_base = os.path.join(base_dir, "10_Wiki", "💡 Topics")
|
|
|
|
batch_files = [
|
|
"3D Gaussian Splatting (3DGS).md",
|
|
"3D Web-based HMI.md",
|
|
"ABA(Applied Behavior Analysis).md",
|
|
"Abstract Syntax Tree (AST).md",
|
|
"Accessibility (A11y).md",
|
|
"Addiction Neuroscience.md",
|
|
"Adaptive-Learning-Systems.md",
|
|
"Adversarial Attack (적대적 공격).md",
|
|
"ACL-Injury-Prevention-Protocols.md",
|
|
"API-First Architecture.md"
|
|
]
|
|
|
|
mapping = {
|
|
"3D Gaussian Splatting (3DGS).md": "Graphics & Performance",
|
|
"3D Web-based HMI.md": "Automation & Industry",
|
|
"ABA(Applied Behavior Analysis).md": "Psychology & Behavior",
|
|
"Abstract Syntax Tree (AST).md": "Programming & Language",
|
|
"Accessibility (A11y).md": "Design & Experience",
|
|
"Addiction Neuroscience.md": "Psychology & Behavior",
|
|
"Adaptive-Learning-Systems.md": "Education & AI",
|
|
"Adversarial Attack (적대적 공격).md": "Security & AI",
|
|
"ACL-Injury-Prevention-Protocols.md": "Health & Science",
|
|
"API-First Architecture.md": "Software Architecture"
|
|
}
|
|
|
|
def wikify(filename):
|
|
raw_path = os.path.join(raw_dir, filename)
|
|
if not os.path.exists(raw_path):
|
|
print(f"File not found: {raw_path}")
|
|
return
|
|
|
|
with open(raw_path, "r", encoding="utf-8") as f:
|
|
content = f.read()
|
|
|
|
title_match = re.search(r'^#\s*\[\[(.*?)\]\]', content, re.M)
|
|
if not title_match:
|
|
title_match = re.search(r'^\[\[(.*?)\]\]', content, re.M)
|
|
|
|
title = title_match.group(1) if title_match else filename.replace(".md", "")
|
|
sub_folder = mapping.get(filename, "Uncategorized")
|
|
category_path = f"10_Wiki/💡 Topics/{sub_folder}"
|
|
|
|
# Extract sections
|
|
summary_match = re.search(r'##?\s*📌\s*Brief Summary\n(.*?)(?=\n##|$)', content, re.S)
|
|
summary = summary_match.group(1).strip() if summary_match else ""
|
|
|
|
core_match = re.search(r'##?\s*📖\s*Core Content\n(.*?)(?=\n##|$)', content, re.S)
|
|
core = core_match.group(1).strip() if core_match else ""
|
|
|
|
conn_match = re.search(r'##?\s*🔗\s*Knowledge Connections\n(.*?)(?=\n##|$)', content, re.S)
|
|
conn = conn_match.group(1).strip() if conn_match else ""
|
|
|
|
doc_id = f"P-REINFORCE-AI-{uuid.uuid4().hex[:6].upper()}"
|
|
today = datetime.now().strftime("%Y-%m-%d")
|
|
|
|
wiki_content = f"""---
|
|
id: {doc_id}
|
|
category: "[[{category_path}]]"
|
|
confidence_score: 0.95
|
|
tags: []
|
|
last_reinforced: {today}
|
|
github_commit: "[P-Reinforce] Batch 9 - Wikified {title}"
|
|
---
|
|
|
|
# [[{title}]]
|
|
|
|
## 📌 한 줄 통찰 (The Karpathy Summary)
|
|
> {summary}
|
|
|
|
## 📖 구조화된 지식 (Synthesized Content)
|
|
{core}
|
|
|
|
## ⚠️ 모순 및 업데이트 (Contradictions & RL Update)
|
|
- **과거 데이터와의 충돌:** 신규 문서로, 기존 정보와의 충돌 분석 예정.
|
|
- **정책 변화:** {sub_folder} 카테고리의 지식 연결망 강화를 위한 표준 위키화 적용.
|
|
|
|
## 🔗 지식 연결 (Graph)
|
|
{conn}
|
|
- Raw Source: [[00_Raw/2026-04-20/{filename}]]
|
|
---
|
|
"""
|
|
|
|
target_dir = os.path.join(base_dir, category_path.replace("/", os.sep))
|
|
if not os.path.exists(target_dir):
|
|
os.makedirs(target_dir)
|
|
|
|
target_path = os.path.join(target_dir, f"{title}.md")
|
|
with open(target_path, "w", encoding="utf-8") as f:
|
|
f.write(wiki_content)
|
|
print(f"Processed: {filename} -> {target_path}")
|
|
|
|
if __name__ == "__main__":
|
|
for f in batch_files:
|
|
wikify(f)
|