#!/usr/bin/env python3 import json from pathlib import Path def load_json(data_dir: Path, filename: str) -> dict: filepath = data_dir / filename if not filepath.exists(): print(f"Warning: {filename} not found") return {} with open(filepath, "r") as f: return json.load(f) def render_html( variables: dict, statistics: dict, sections: dict, graph: dict, charts: dict ) -> str: html_template = ( """ Claude's Constitution Analysis System

Claude's Constitution Analysis System

Overview Dashboard

Priority Distribution

Constraint Distribution

Variables

Document Sections

Variable Network Graph

Statistical Analysis

Variable Categories

Sentence Length Distribution

""" ) return html_template def generate_html_interface(): base_dir = Path(__file__).parent.parent.parent data_dir = base_dir / "constitution_analysis" / "data" web_dir = base_dir / "constitution_analysis" / "web" web_dir.mkdir(exist_ok=True) print("Loading data files...") variables = load_json(data_dir, "variables.json") statistics = load_json(data_dir, "statistics.json") sections = load_json(data_dir, "sections.json") graph = load_json(data_dir, "graph.json") charts = load_json(data_dir, "charts.json") print("Generating HTML interface...") html_content = render_html(variables, statistics, sections, graph, charts) output_path = web_dir / "index.html" with open(output_path, "w") as f: f.write(html_content) print(f"✓ HTML interface generated at {output_path}") print(f" Open in browser: firefox {output_path}") if __name__ == "__main__": generate_html_interface()