#!/usr/bin/env python3 """ 脚本结果可视化工具 V2 功能:为 output_demo_script_v2.json 中的每个视频生成独立的HTML可视化页面,专门展示"整体结构理解"的结果 """ import json import argparse import sys from pathlib import Path from datetime import datetime from typing import List, Dict, Any, Optional import html as html_module # 保证可以从项目根目录导入 PROJECT_ROOT = Path(__file__).parent.parent if str(PROJECT_ROOT) not in sys.path: sys.path.insert(0, str(PROJECT_ROOT)) class ScriptResultVisualizerV2: """脚本结果可视化器 V2 - 专门展示整体结构理解""" def __init__(self, json_file: str = None): """ 初始化可视化器 Args: json_file: JSON文件路径 """ if json_file is None: self.json_file = None else: self.json_file = Path(json_file) if not self.json_file.is_absolute(): self.json_file = Path.cwd() / json_file def load_json_data(self, file_path: Path) -> Optional[Dict[str, Any]]: """ 加载JSON文件 Args: file_path: JSON文件路径 Returns: JSON数据字典,加载失败返回None """ try: with open(file_path, 'r', encoding='utf-8') as f: return json.load(f) except Exception as e: print(f"加载文件失败 {file_path}: {e}") return None def generate_overall_structure_section(self, overall_data: Dict[str, Any], section_idx: int = 0) -> str: """生成整体解构部分HTML""" html = '
暂无段落数据
\n' html += '