Context: Unified Modeling Language (UML) is widely used in software engineering education to teach system analysis and design. However, manually translating textual software specifications into consistent UML diagrams is challenging for learners due to ambiguity, inconsistent interpretation, and the lack of cross-diagram alignment. Existing NLP- and LLM-based approaches generate diagrams but often lack a unified intermediate representation to ensure structural consistency and explainability. Objective: This study aims to develop a unified graph-based intermediate representation, called UMLGraphIR, designed to provide interpretable feedback for learners through graph-based structural analysis. The goal is to enable reliable transformation of textual specifications into consistent UML diagrams through a structured workflow while supporting explainable evaluation and validation. Methods: The proposed framework follows a multi-stage transformation pipeline: (1) extracting actors, actions, and relationships using an LLM-based component identification process; (2) representing these elements using a structured JSON schema; (3) converting the JSON into a weighted adjacency matrix encoding UML relationships such as association, include, and extend; and (4) generating a canonical graph using Graphviz and PlantUML for visualization and validation. A Library Management System case study demonstrates the process, and evaluation is performed through graph-based structural comparison with instructor-defined reference diagrams. Results: The framework successfully generated use case, class, and sequence diagrams with improved structural alignment and semantic accuracy, achieving a mean structural accuracy of 92.58% across 20 software specifications compared to 68.62% for student-generated baselines. The unified graph-based representation enhanced cross-diagram consistency, enabled quantifiable structural validation through node convergence (94.1%), edge convergence (90.9%), and relationship type accuracy (92.3%), and reduced modeling errors commonly found in student-generated diagrams. A pilot observational study further showed that students who revised their diagrams using UMLGraphIR-generated feedback improved their mean accuracy to 88.50%. The UMLGraphIR Streamlit prototype demonstrated the practical feasibility of graph-based UML generation, validation, and feedback delivery, providing interpretable feedback through graph-level identification of missing elements, relationship mismatches, and structural inconsistencies. Conclusion: UMLGraphIR offers a consistent, explainable, and scalable approach for transforming textual specifications into UML diagrams. By establishing a unified graph-based representation, the framework improves diagram quality, supports cross-diagram coherence, and enhances educational feedback mechanisms. The approach provides a foundation for future extensions such as multimodal inputs, additional UML diagram types, and broader integration into model-driven engineering workflows.
更多