import os import re import uuid import sys from datetime import datetime # UTF-8 Output support 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") batch_files = [ "Aerospace Flight Simulation.md", "Affective Computing.md", "Affective User Interfaces (AUI).md", "Agency and Player Autonomy.md", "Agent-Based Modeling (ABM).md", "Agile-UX-Integration.md", "AI Connect LLM Tool.md", "AI-Driven Narrative Systems.md", "Accessibility-Compliance-WCAG.md", "Advanced-Design-Patterns-in-TypeScript.md" ] mapping = { "Aerospace Flight Simulation.md": "Physics & Simulation", "Affective Computing.md": "AI & Psychology", "Affective User Interfaces (AUI).md": "Design & Experience", "Agency and Player Autonomy.md": "Game Design", "Agent-Based Modeling (ABM).md": "Simulation & Math", "Agile-UX-Integration.md": "Design & Experience", "AI Connect LLM Tool.md": "AI & Tools", "AI-Driven Narrative Systems.md": "AI & Narrative", "Accessibility-Compliance-WCAG.md": "Design & Experience", "Advanced-Design-Patterns-in-TypeScript.md": "Programming & Language" } 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 simplified for automation 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-{uuid.uuid4().hex[:6].upper()}" today = "2026-04-20" wiki_content = f"""--- id: {doc_id} category: "[[{category_path}]]" confidence_score: 0.95 tags: [] last_reinforced: {today} github_commit: "[P-Reinforce] Batch 10 - 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)