KG to B-UML¶
- besser.utilities.kg_to_buml.clean_json_response(response: str) str[source]¶
Clean JSON response from LLM (remove markdown formatting)
- besser.utilities.kg_to_buml.clean_plantuml_response(response: str) str[source]¶
Clean PlantUML response from LLM (remove markdown formatting)
- besser.utilities.kg_to_buml.convert_spec_json_to_buml(system_spec, title='KG Imported Diagram')[source]¶
Convert class specifications from GPT-generated JSON to Apollon/BUML format.
- besser.utilities.kg_to_buml.kg_to_buml(kg_path: str, openai_token: str, openai_model: str = 'gpt-4o')[source]¶
Convert a Knowledge Graph (KG) into a B-UML class diagram.
Supported inputs
Turtle files (.ttl)
RDF KGs (.rdf files)
Neo4j graphs (JSON) exported using the Cypher command below:
CALL apoc.export.json.all(null, {stream:true, pretty:true}) YIELD data RETURN data AS json
The function reads the KG (TTL/RDF or Neo4j JSON export), extracts classes, attributes, methods, and associations, and uses an LLM to generate a DomainModel object defined in besser.BUML.metamodel.structural.
- besser.utilities.kg_to_buml.kg_to_plantuml(kg_path: str, openai_token: str, openai_model: str = 'gpt-4o')[source]¶
Transform a Knowledge Graph (KG) into a PlantUML class diagram.
Supported inputs:
Turtle files (.ttl)
RDF KGs (.rdf files)
Neo4j graphs (JSON) exported using the Cypher command below:
CALL apoc.export.json.all(null, {stream:true, pretty:true}) YIELD data RETURN data AS json
The function extracts classes, attributes, methods, and associations from the KG and asks an LLM to produce a complete PlantUML class diagram using only the data types defined in besser.BUML.metamodel.structural.