json2graph.library

The library.py module serves as a versatile and user-friendly library within the broader ontouml-json2graph package.

It offers a streamlined way for users to convert OntoUML model data in JSON format into RDF graphs that adhere to the OntoUML Vocabulary. By encapsulating the underlying functionalities, this library empowers users to effortlessly integrate OntoUML JSON conversion capabilities into their projects.

In addition to conversion functions, the library provides the save_graph_file utility, enabling users to safely save OntoUML graphs to files in their desired syntax.

Module Contents

Functions

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

Decode elements from OntoUML's abstract and concrete syntax from JSON format into a Knowledge Graph. I.e., domain-level and diagrammatic data are converted to Knowledge Graph.

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

Decode elements from OntoUML's abstract syntax from JSON format into a Knowledge Graph. I.e., only domain-level (and not diagrammatic) data is converted to Knowledge Graph.

save_graph_file(ontouml_graph, output_file_path, syntax)

Is designed to securely save an OntoUML graph, represented as an RDFLib's Graph object, into a file at a specified destination while using the user's informed syntax.

json2graph.library.decode_json_project(json_file_path, base_uri='https://example.org#', language='', correct=False)

Decode elements from OntoUML’s abstract and concrete syntax from JSON format into a Knowledge Graph. I.e., domain-level and diagrammatic data are converted to Knowledge Graph.

This function decodes OntoUML JSON data representing a project-level model into a knowledge graph that adheres to the OntoUML Vocabulary. It provides customization options for URI generation, language tags, error correction, and returns the resulting knowledge graph.

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) This tag specifies the language in which labels and descriptions are provided.

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

Returns:

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

Return type:

Graph

json2graph.library.decode_json_model(json_file_path, base_uri='https://example.org#', language='', correct=False)

Decode elements from OntoUML’s abstract syntax from JSON format into a Knowledge Graph. I.e., only domain-level (and not diagrammatic) data is converted to Knowledge Graph.

This function decodes OntoUML JSON data representing a model-level view into a knowledge graph that adheres to the OntoUML Vocabulary. It provides customization options for URI generation, language tags, error correction, and returns the resulting knowledge graph.

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) This tag specifies the language in which labels and descriptions are provided.

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

Returns:

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

Return type:

Graph

json2graph.library.save_graph_file(ontouml_graph, output_file_path, syntax)

Is designed to securely save an OntoUML graph, represented as an RDFLib’s Graph object, into a file at a specified destination while using the user’s informed syntax.

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

  • output_file_path (str) – Complete path of the output file to be created (including name and extension).

  • syntax (str) – Syntax to be used for saving the ontology file. A syntax allowed by RDFLib must be informed.

Return type:

None