json2graph.decode

Main function used as script to convert OntoUML JSON files into knowledge graphs, with the flexibility to customize the output and control the execution mode for different use cases.

Module Contents

Functions

decode_ontouml_json2graph(json_file_path[, base_uri, ...])

Convert OntoUML JSON data to a Knowledge Graph.

write_graph_file(ontouml_graph[, execution_mode])

Save the ontology graph received as argument into a file using the syntax defined by the user.

decode_all_ontouml_json2graph()

Decode multiple OntoUML JSON files in batch mode.

Attributes

decoded_graph

json2graph.decode.decode_ontouml_json2graph(json_file_path, base_uri='https://example.org#', language='', model_only=False, silent=True, correct=False, execution_mode='import')

Convert OntoUML JSON data to a Knowledge Graph.

This function takes the path to a JSON file representing OntoUML model data provided by the user and converts it into a knowledge graph following the specified options.

Parameters:
  • json_file_path (str) – Path to the JSON file to be decoded provided by the user.

  • base_uri (str) – Base URI to be used for generating URIs for ontology concepts. Default is https://example.org#. (Optional)

  • language (str) – Language tag to be added to the ontology’s concepts. (Optional)

  • model_only (bool) – If True, only the OntoUML model will be extracted without diagrammatic information. (Optional)

  • silent (bool) – If True, suppresses intermediate communications and log messages during execution. (Optional)

  • correct (bool) – If True, attempts to correct potential errors during the conversion process. (Optional)

  • execution_mode (str) – Information about the execution mode. Valid values are ‘import’ (default), ‘script’, and ‘test’. (Optional)

Returns:

JSON data decoded into a RDFLib’s Graph that is compliant with the OntoUML Vocabulary.

Return type:

Graph

json2graph.decode.write_graph_file(ontouml_graph, execution_mode='script')

Save the ontology graph received as argument into a file using the syntax defined by the user.

When running in script mode, the result is saved in the folder specified by the user as argument. When running in test mode, the file is saved inside the ‘results’ directory created by this function.

Parameters:
  • ontouml_graph (Graph) – Graph compliant with the OntoUML Vocabulary.

  • execution_mode (str) – Information about the execution mode. Valid values are ‘import’ (default), ‘script’, and ‘test’. (Optional)

Returns:

Saved output file path.

Return type:

str

json2graph.decode.decode_all_ontouml_json2graph()

Decode multiple OntoUML JSON files in batch mode.

This function processes a directory of OntoUML JSON files and converts each file into a corresponding knowledge graph using the specified options. The output graphs are saved in the output directory chosen by the user as argument.

Return type:

None

json2graph.decode.decoded_graph