[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.8214977.svg)](https://doi.org/10.5281/zenodo.8214977)
[![Project Status - Active](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
![GitHub - Release Date - PublishedAt](https://img.shields.io/github/release-date/ontouml/ontouml-json2graph)
![GitHub - Last Commit - Branch](https://img.shields.io/github/last-commit/ontouml/ontouml-json2graph/main)
![PyPI - Project](https://img.shields.io/pypi/v/ontouml-json2graph)
![Language - Top](https://img.shields.io/github/languages/top/ontouml/ontouml-json2graph)
![Language - Version](https://img.shields.io/pypi/pyversions/ontouml-json2graph)
![CodeFactor Grade](https://img.shields.io/codefactor/grade/github/ontouml/ontouml-json2graph)
![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/OntoUML/ontouml-json2graph/badge)
![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)
![License - GitHub](https://img.shields.io/github/license/ontouml/ontouml-json2graph)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](https://github.com/pre-commit/pre-commit)
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/OntoUML/ontouml-json2graph/main.svg)](https://results.pre-commit.ci/latest/github/OntoUML/ontouml-json2graph/main)
![Website](https://img.shields.io/website/http/ontouml.github.io/ontouml-json2graph.svg)
![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/ontouml/ontouml-json2graph/code_testing.yml)
# The OntoUML JSON2Graph Transformation
<p align="center"><img src="https://raw.githubusercontent.com/OntoUML/ontouml-json2graph/main/json2graph/resources/logo-json2graph.png" width="740"></p>
The OntoUML JSON2Graph (ontouml-json2graph) decodes a JSON file that complies with the [ontouml-schema](https://w3id.org/ontouml/schema) (e.g., the ones exported by the [ontouml-vp-plugin](https://github.com/OntoUML/ontouml-vp-plugin)) to a graph file that complies with the [ontouml-vocabulary](https://github.com/OntoUML/ontouml-vocabulary).
When transforming a model, you can choose to represent only the core concepts of the model or include all of its information, including diagrammatic elements, as part of the knowledge graph. Additionally, users have the choice to enable basic semantic and syntactical verifications, ensuring enhanced and accurate transformation results.
This application was developed using the [RDFLib](https://rdflib.readthedocs.io/en/stable/) and Python 3.11. The generated graph file can be serialized in the diverse [formats supported by the RDFLib](https://rdflib.readthedocs.io/en/stable/intro_to_parsing.html#saving-rdf), which are Turtle, RDF/XML, JSON-LD, N-Triples, Notation-3, Trig, Trix, and N-Quads.
**📦 PyPI Package:**
The transformation is conveniently [available as a PyPI package](https://pypi.org/project/ontouml-json2graph/), which allows users to use it as an executable script or import it as a library into other Python projects.
**📚 Code Documentation:**
For inquiries and further information, please refer to the [comprehensive docstring-generated documentation](https://w3id.org/ontouml/json2graph/docs) available for this project.
## Contents
<!-- TOC -->
* [The OntoUML JSON2Graph Transformation](#the-ontouml-json2graph-transformation)
* [Contents](#contents)
* [Installation](#installation)
* [Usage](#usage)
* [Executing as a Script](#executing-as-a-script)
* [Arguments](#arguments)
* [Importing as a Library](#importing-as-a-library)
* [decode_json_project](#decodejsonproject)
* [decode_json_model](#decodejsonmodel)
* [save_graph_file](#savegraphfile)
* [Input and Output](#input-and-output)
* [OntoUML Vocabulary and gUFO](#ontouml-vocabulary-and-gufo)
* [Basic Syntactical and Sematic Validation](#basic-syntactical-and-sematic-validation)
* [Permanent URLs and Identifiers](#permanent-urls-and-identifiers)
* [Related Projects](#related-projects)
* [Development Contribution](#development-contribution)
* [Author](#author)
<!-- TOC -->
## Installation
Before using the OntoUML JSON2Graph Decoder, you need to [download and install Python](https://www.python.org/downloads/). To install the application you simply need to perform the following command:
```text
pip install ontouml-json2graph
```
All dependencies will be installed automatically, and you will be ready to use the ontouml-json2graph package.
## Usage
After being installed, the OntoUML JSON2Graph Decoder can be used as an **executable script** or **imported as a library** into another Python project.
The output of the transformation, i.e., the graph file, will be saved into a directory named `results` in the same path in which the software was executed.
### Executing as a Script
For executing the software, run the following command on the terminal inside the project's folder:
```txt
python -m json2graph.decode -i [path_to_json] [OPTIONAL ARGUMENTS]
```
For example, to decode the JSON file `my_ontology.json` and save the output graph in the Turtle format, you would run the following command:
```txt
python -m json2graph.decode -i turtle my_ontology.json
```
You can also use the script to decode multiple JSON files. To do this, you would use the `decode_all` option ('-a' argument).
For example, to decode all the JSON files in 'my_data' directory you have to run the following command:
```txt
python -m json2graph.decode -a -i my_data
```
#### Arguments
The only mandatory argument is `path_to_json`, which must be substituted for the input file's location on your computer.
Optional arguments provide additional features. All available ontouml-json2graph arguments can be observed below.
```text
usage: ontouml-json2graph [-h] -i INPUT_PATH [-o OUTPUT_PATH] [-a] [-f {turtle,ttl,turtle2,xml,pretty-xml,json-ld,ntriples,nt,nt11,n3,trig,trix,nquads}]
[-l LANGUAGE] [-c] [-s] [-u BASE_URI] [-m] [-v]
OntoUML JSON2Graph Decoder. Version: 1.3.1
options:
-h, --help show this help message and exit
-i INPUT_PATH, --input_path INPUT_PATH
The path of the JSON file or directory with JSON files to be decoded.
-o OUTPUT_PATH, --output_path OUTPUT_PATH
The path of the directory in which the resulting decoded file(s) will be saved. Default is the working directory.
-a, --decode_all Converts all JSON files in the informed path.
-f {turtle,ttl,turtle2,xml,pretty-xml,json-ld,ntriples,nt,nt11,n3,trig,trix,nquads}, --format {turtle,ttl,turtle2,xml,pretty-xml,json-ld,ntriples,nt,nt11,n3,trig,trix,nquads}
Format to save the decoded file. Default is 'ttl'.
-l LANGUAGE, --language LANGUAGE
Language tag for the ontology's concepts. Default is 'None'.
-c, --correct Enables syntactical and semantic validations and corrections.
-s, --silent Silent mode. Does not present validation warnings and errors.
-u BASE_URI, --base_uri BASE_URI
Base URI of the resulting graph. Default is 'https://example.org#'.
-m, --model_only Keep only model elements, eliminating all diagrammatic data from output.
-v, --version Print the software version and exit.
More information at: https://w3id.org/ontouml/json2graph
```
### Importing as a Library
The `library.py` module ([full documentation](https://dev.ontouml.org/ontouml-json2graph/autoapi/json2graph/library/index.html)) is a user-friendly component of the `ontouml-json2graph` package. By encapsulating complex functionalities, this library empowers users to seamlessly integrate OntoUML JSON conversion capabilities into their projects. In addition to conversion functions, the library provides a utility function for safely saving OntoUML graphs to files in the desired syntax.
The library provides the following functions for decoding OntoUML JSON data and saving OntoUML graphs to files:
#### decode_json_project
The `decode_json_project` function allows you to decode the complete OntoUML JSON data (including elements from OntoUML's abstract and concrete syntax) into a knowledge graph that conforms to the OntoUML Vocabulary. This function provides customization options, such as specifying the base URI for ontology concepts, adding language tags, and enabling error correction. With this function domain-level and diagrammatic data are converted to Knowledge Graph.
```python
from json2graph.library import decode_json_project
decoded_graph_project = decode_json_project(json_file_path="path/to/input.json", base_uri="https://myuri.org#",
language="en", correct=True)
```
#### decode_json_model
The `decode_json_model` function decodes OntoUML JSON data representing a model-level view into a knowledge graph that adheres to the OntoUML Vocabulary.
Differently from the `decode_json_model`, this function decodes only elements from the OntoUML's abstract syntax. I.e., only domain-level (and not diagrammatic) data is converted to knowledge graph. It offers options for base URI, language tags, and error correction.
```python
from json2graph.library import decode_json_model
decoded_graph_model = decode_json_model(json_file_path="path/to/input.json", base_uri="https://myuri.org#",
language="en",
correct=True)
```
#### save_graph_file
The `save_graph_file` utility function provides a convenient way to save an OntoUML graph as an RDF file in the desired syntax.
```python
from json2graph.library import save_graph_file
output_file_path = "./output_graph.ttl"
syntax = "ttl" # Choose the desired syntax: "xml", "n3", "nt", etc.
save_graph_file(ontouml_graph, output_file_path, syntax)
```
The valid syntax options are the ones that [can be parsed by the RDFLib](https://rdflib.readthedocs.io/en/stable/intro_to_parsing.html#saving-rdf): turtle, ttl, turtle2, xml, pretty-xml, json-ld, ntriples, nt, nt11, n3, trig, trix, and nquads.
### Input and Output
This software's **input
** is a JSON file that complies with the [OntoUML Schema](https://w3id.org/ontouml/schema). This JSON file can be obtained from the [ontouml-vp-plugin](https://w3id.org/ontouml/vp-plugin)'s export feature. The JSON2Graph Decoder was tested to guarantee its compatibility with the JSON generated by the plugin's [version 0.5.3](https://w3id.org/ontouml/vp-plugin/v0.5.3).
The transformation's **output
** corresponds to the OntoUML Model serialized as a graph. The saved file information is described by the [OntoUML Vocabulary](https://w3id.org/ontouml/vocabulary) and can be saved in the [different formats that are supported by the RDFLib](https://rdflib.readthedocs.io/en/stable/intro_to_parsing.html#saving-rdf).
This output graph may contain the model's diagrammatic information or not, depending on the user's provided arguments.
The [OntoUML Vocabulary documentation](https://dev.ontouml.org/ontouml-vocabulary/#mozTocId376551) contains a usage overview, presenting information about all available elements, and about how to use them, including examples of SPARQL queries.
Both the input and output of the software are built upon the same metamodel, the [OntoUML Metamodel](https://w3id.org/ontouml/metamodel), which facilitates the conversion between different representations.
### OntoUML Vocabulary and gUFO
The ontouml-vp-plugin has a feature that enables an ontology to be transformed from OntoUML to a graph format. This feature is called the [Model Transformation to OWL with gUFO](https://github.com/OntoUML/ontouml-vp-plugin/#model-transformation-to-owl-with-gufo).
**[gUFO](https://nemo-ufes.github.io/gufo/)** is a lightweight implementation of the OntoUML's underlying foundational ontology, the Unified Foundational
Ontology (UFO).
Even though an ontology represented in gUFO and in the OntoUML Vocabulary are both suitable for Semantic Web OWL 2 DL applications, these two representations are different and were created with different purposes.
gUFO is intended for reuse in the definition of UFO-based lightweight ontologies. Reuse of gUFO consists in instantiating and/or specializing the various entities defined in the ontology, inheriting from it the domain-independent distinctions of UFO. A key feature of UFO (and hence, gUFO) is that it includes two taxonomies: one with classes whose instances are individuals (classes in this taxonomy include gufo:Object, gufo:Event) and another with classes whose instances are types (classes in this taxonomy include gufo:Kind, gufo:Phase, gufo:Category).
Differently, the OntoUML Vocabulary was created to support the serialization, exchange, publishing of OntoUML as linked data, and to be used in Semantic Web applications. Models in this format are machine-readable resources intended to support the needs of tool developers and researchers, enabling the performance of complex analysis using the SPARQL querying language with no need for additional software. In addition, as it contains the concrete elements (i.e., diagrammatic data such as diagrams and diagram elements) of OntoUML projects, it can also be used to fully reconstruct the original models.
## Basic Syntactical and Sematic Validation
- Class validations:
- Reports Class with incompatible attributes isExtensional (not 'null') and isPowertype (set as 'True').
- Sets Class stereotype as 'collective' when the Class's stereotype is 'null' and its isExtensional attribute is 'True'.
- Sets Class stereotype as 'type' when the Class's stereotype is 'null' and its isPowertype attribute is 'True'.
- Removes the Class's isExtensional attribute if the Class's stereotype is not 'collective'.
- Sets the Class's isPowertype attribute as 'False' if the Class's stereotype is not 'type'.
- Sets the Class's order attribute to '1' if the Class's stereotype is not 'type' and its order different from '1'.
- Sets the Class's order attribute to '2' if the Class's stereotype is 'type' and its order is '1'.
- Reports mandatory Class stereotype missing.
- Stereotype validations:
- Reports invalid Class stereotype assigned (i.e., assigned stereotype is not in enumeration class ClassStereotype).
- Reports invalid Relation stereotype assigned (i.e., assigned stereotype is not in enumeration class RelationStereotype).
- Reports invalid Property stereotype assigned (i.e., assigned stereotype is not in enumeration class
PropertyStereotype).
- Property validations:
- Reports invalid assertion when a Property stereotype is related to a Class that is known not to be of stereotype 'event'.
- Sets Class stereotype as 'event' when it is originally 'null' and the class is related to a Property with stereotype.
## Permanent URLs and Identifiers
- Repository: [https://w3id.org/ontouml/json2graph](https://w3id.org/ontouml/json2graph)
- Documentation: [https://w3id.org/ontouml/json2graph/docs](https://w3id.org/ontouml/json2graph/docs)
- Releases:
- All releases: [https://w3id.org/ontouml/json2graph/releases](https://w3id.org/ontouml/json2graph/releases)
- Latest release: [https://w3id.org/ontouml/json2graph/latest](https://w3id.org/ontouml/json2graph/latest)
- Specific release: https://w3id.org/ontouml/json2graph/v<n>, where \<n\> represents the version number (e.g., '1.0.0')
## Related Projects
- **[OntoUML Metamodel](https://w3id.org/ontouml/metamodel)**:
Implementation-independent OntoUML Metamodel. Unlike the UML profile, this version is independent of UML and presents only the concepts officially supported in the language. This metamodel covers the abstract and concrete syntaxes of the language and serves as the reference for all projects in the [OntoUML as a Service (OaaS)](https://ceur-ws.org/Vol-2969/paper29-FOMI.pdf) ecosystem, including its different model serializations.
- **[OntoUML Vocabulary](https://w3id.org/ontouml/vocabulary)**:
An OntoUML Metamodel's serialization in Turtle (ttl) format. This vocabulary supports the serialization, exchange, and publishing of OntoUML models as graphs that can be used for Semantic Web and Linked Data applications.
- **[OntoUML Schema](https://w3id.org/ontouml/schema)**:
An OntoUML Metamodel's serialization in JSON format. The JSON is a format better suited for manipulation within software code. It supports the exchange of models between modeling tools and the OntoUML server, providing model intelligent services.
- **[ontouml-vp-plugin](https://w3id.org/ontouml/vp-plugin)**:
The OntoUML Plugin for Visual Paradigm adds features designed for OntoUML modelers to any version of the Visual Paradigm - a modeling editor that provides a [free for non-commercial version](https://www.visual-paradigm.com/download/community.jsp).
These features range from enabling OntoUML stereotypes in class diagrams to model verification and transformation.
## Development Contribution
We encourage you to contribute to the development of this software.
The dependencies to develop this software are not the same as the ones to execute it. Hence, it is necessary run the following command on the terminal inside the project's folder to install all necessary dependencies:
```text
pip install -r requirements.txt
```
You also need run `pre-commit install` to set up the git hook scripts.
The ontouml-json2graph package was developed using test-driven-based development. Multiple tests are available inside the following folder: `ontouml-json2graph/json2graph/tests`. To execute the tests, run the following command from inside the project's root folder:
```text
pytest .\json2graph\tests\test_main.py
```
The tests' code documentation [is also available](https://dev.ontouml.org/ontouml-json2graph/autoapi/json2graph/tests/index.html).
## Author
This project is maintained by the [Semantics, Cybersecurity & Services (SCS) Group](https://www.utwente.nl/en/eemcs/scs/) of the [University of Twente](https://www.utwente.nl/), The Netherlands. Its developer is:
- [Pedro Paulo Favato Barcelos](https://orcid.org/0000-0003-2736-7817) [[GitHub](https://github.com/pedropaulofb)] [[LinkedIn](https://www.linkedin.com/in/pedro-paulo-favato-barcelos/)]
Feel free to get in touch using the provided links. For questions, contributions, or to report any problem, you can **[open an issue](https://github.com/OntoUML/ontouml-json2graph/issues)** at this repository.
Raw data
{
"_id": null,
"home_page": "https://w3id.org/ontouml/json2graph",
"name": "ontouml-json2graph",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.9,<4.0",
"maintainer_email": "",
"keywords": "semantic-web,knowledge-graph,ontouml,ontology-driven-development,ontouml-schema,ontouml-vocabulary,ontouml-metamodel",
"author": "Pedro Paulo F. Barcelos",
"author_email": "p.p.favatobarcelos@utwente.nl",
"download_url": "https://files.pythonhosted.org/packages/b2/40/0f0985b55a0ef8a536cdabfffc33c11481135e1b59dffe34886f7807ced2/ontouml_json2graph-1.3.2.tar.gz",
"platform": null,
"description": "[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.8214977.svg)](https://doi.org/10.5281/zenodo.8214977)\n[![Project Status - Active](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)\n![GitHub - Release Date - PublishedAt](https://img.shields.io/github/release-date/ontouml/ontouml-json2graph)\n![GitHub - Last Commit - Branch](https://img.shields.io/github/last-commit/ontouml/ontouml-json2graph/main)\n![PyPI - Project](https://img.shields.io/pypi/v/ontouml-json2graph)\n![Language - Top](https://img.shields.io/github/languages/top/ontouml/ontouml-json2graph)\n![Language - Version](https://img.shields.io/pypi/pyversions/ontouml-json2graph)\n![CodeFactor Grade](https://img.shields.io/codefactor/grade/github/ontouml/ontouml-json2graph)\n![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/OntoUML/ontouml-json2graph/badge)\n![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)\n![License - GitHub](https://img.shields.io/github/license/ontouml/ontouml-json2graph)\n[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](https://github.com/pre-commit/pre-commit)\n[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/OntoUML/ontouml-json2graph/main.svg)](https://results.pre-commit.ci/latest/github/OntoUML/ontouml-json2graph/main)\n![Website](https://img.shields.io/website/http/ontouml.github.io/ontouml-json2graph.svg)\n![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/ontouml/ontouml-json2graph/code_testing.yml)\n\n# The OntoUML JSON2Graph Transformation\n\n<p align=\"center\"><img src=\"https://raw.githubusercontent.com/OntoUML/ontouml-json2graph/main/json2graph/resources/logo-json2graph.png\" width=\"740\"></p>\n\nThe OntoUML JSON2Graph (ontouml-json2graph) decodes a JSON file that complies with the [ontouml-schema](https://w3id.org/ontouml/schema) (e.g., the ones exported by the [ontouml-vp-plugin](https://github.com/OntoUML/ontouml-vp-plugin)) to a graph file that complies with the [ontouml-vocabulary](https://github.com/OntoUML/ontouml-vocabulary).\n\nWhen transforming a model, you can choose to represent only the core concepts of the model or include all of its information, including diagrammatic elements, as part of the knowledge graph. Additionally, users have the choice to enable basic semantic and syntactical verifications, ensuring enhanced and accurate transformation results.\n\nThis application was developed using the [RDFLib](https://rdflib.readthedocs.io/en/stable/) and Python 3.11. The generated graph file can be serialized in the diverse [formats supported by the RDFLib](https://rdflib.readthedocs.io/en/stable/intro_to_parsing.html#saving-rdf), which are Turtle, RDF/XML, JSON-LD, N-Triples, Notation-3, Trig, Trix, and N-Quads.\n\n**\ud83d\udce6 PyPI Package:**\nThe transformation is conveniently [available as a PyPI package](https://pypi.org/project/ontouml-json2graph/), which allows users to use it as an executable script or import it as a library into other Python projects.\n\n**\ud83d\udcda Code Documentation:**\nFor inquiries and further information, please refer to the [comprehensive docstring-generated documentation](https://w3id.org/ontouml/json2graph/docs) available for this project.\n\n## Contents\n\n<!-- TOC -->\n\n* [The OntoUML JSON2Graph Transformation](#the-ontouml-json2graph-transformation)\n * [Contents](#contents)\n * [Installation](#installation)\n * [Usage](#usage)\n * [Executing as a Script](#executing-as-a-script)\n * [Arguments](#arguments)\n * [Importing as a Library](#importing-as-a-library)\n * [decode_json_project](#decodejsonproject)\n * [decode_json_model](#decodejsonmodel)\n * [save_graph_file](#savegraphfile)\n * [Input and Output](#input-and-output)\n * [OntoUML Vocabulary and gUFO](#ontouml-vocabulary-and-gufo)\n * [Basic Syntactical and Sematic Validation](#basic-syntactical-and-sematic-validation)\n * [Permanent URLs and Identifiers](#permanent-urls-and-identifiers)\n * [Related Projects](#related-projects)\n * [Development Contribution](#development-contribution)\n * [Author](#author)\n\n<!-- TOC -->\n\n## Installation\n\nBefore using the OntoUML JSON2Graph Decoder, you need to [download and install Python](https://www.python.org/downloads/). To install the application you simply need to perform the following command:\n\n```text\npip install ontouml-json2graph\n```\n\nAll dependencies will be installed automatically, and you will be ready to use the ontouml-json2graph package.\n\n## Usage\n\nAfter being installed, the OntoUML JSON2Graph Decoder can be used as an **executable script** or **imported as a library** into another Python project.\n\nThe output of the transformation, i.e., the graph file, will be saved into a directory named `results` in the same path in which the software was executed.\n\n### Executing as a Script\n\nFor executing the software, run the following command on the terminal inside the project's folder:\n\n```txt\npython -m json2graph.decode -i [path_to_json] [OPTIONAL ARGUMENTS]\n```\n\nFor example, to decode the JSON file `my_ontology.json` and save the output graph in the Turtle format, you would run the following command:\n\n```txt\npython -m json2graph.decode -i turtle my_ontology.json\n```\n\nYou can also use the script to decode multiple JSON files. To do this, you would use the `decode_all` option ('-a' argument).\nFor example, to decode all the JSON files in 'my_data' directory you have to run the following command:\n\n```txt\npython -m json2graph.decode -a -i my_data\n```\n\n#### Arguments\n\nThe only mandatory argument is `path_to_json`, which must be substituted for the input file's location on your computer.\nOptional arguments provide additional features. All available ontouml-json2graph arguments can be observed below.\n\n```text\nusage: ontouml-json2graph [-h] -i INPUT_PATH [-o OUTPUT_PATH] [-a] [-f {turtle,ttl,turtle2,xml,pretty-xml,json-ld,ntriples,nt,nt11,n3,trig,trix,nquads}]\n [-l LANGUAGE] [-c] [-s] [-u BASE_URI] [-m] [-v]\n\nOntoUML JSON2Graph Decoder. Version: 1.3.1\n\noptions:\n -h, --help show this help message and exit\n -i INPUT_PATH, --input_path INPUT_PATH\n The path of the JSON file or directory with JSON files to be decoded.\n -o OUTPUT_PATH, --output_path OUTPUT_PATH\n The path of the directory in which the resulting decoded file(s) will be saved. Default is the working directory.\n -a, --decode_all Converts all JSON files in the informed path.\n -f {turtle,ttl,turtle2,xml,pretty-xml,json-ld,ntriples,nt,nt11,n3,trig,trix,nquads}, --format {turtle,ttl,turtle2,xml,pretty-xml,json-ld,ntriples,nt,nt11,n3,trig,trix,nquads}\n Format to save the decoded file. Default is 'ttl'.\n -l LANGUAGE, --language LANGUAGE\n Language tag for the ontology's concepts. Default is 'None'.\n -c, --correct Enables syntactical and semantic validations and corrections.\n -s, --silent Silent mode. Does not present validation warnings and errors.\n -u BASE_URI, --base_uri BASE_URI\n Base URI of the resulting graph. Default is 'https://example.org#'.\n -m, --model_only Keep only model elements, eliminating all diagrammatic data from output.\n -v, --version Print the software version and exit.\n\nMore information at: https://w3id.org/ontouml/json2graph\n```\n\n### Importing as a Library\n\nThe `library.py` module ([full documentation](https://dev.ontouml.org/ontouml-json2graph/autoapi/json2graph/library/index.html)) is a user-friendly component of the `ontouml-json2graph` package. By encapsulating complex functionalities, this library empowers users to seamlessly integrate OntoUML JSON conversion capabilities into their projects. In addition to conversion functions, the library provides a utility function for safely saving OntoUML graphs to files in the desired syntax.\n\nThe library provides the following functions for decoding OntoUML JSON data and saving OntoUML graphs to files:\n\n#### decode_json_project\n\nThe `decode_json_project` function allows you to decode the complete OntoUML JSON data (including elements from OntoUML's abstract and concrete syntax) into a knowledge graph that conforms to the OntoUML Vocabulary. This function provides customization options, such as specifying the base URI for ontology concepts, adding language tags, and enabling error correction. With this function domain-level and diagrammatic data are converted to Knowledge Graph.\n\n```python\nfrom json2graph.library import decode_json_project\n\ndecoded_graph_project = decode_json_project(json_file_path=\"path/to/input.json\", base_uri=\"https://myuri.org#\",\n language=\"en\", correct=True)\n```\n\n#### decode_json_model\n\nThe `decode_json_model` function decodes OntoUML JSON data representing a model-level view into a knowledge graph that adheres to the OntoUML Vocabulary.\n\nDifferently from the `decode_json_model`, this function decodes only elements from the OntoUML's abstract syntax. I.e., only domain-level (and not diagrammatic) data is converted to knowledge graph. It offers options for base URI, language tags, and error correction.\n\n```python\nfrom json2graph.library import decode_json_model\n\ndecoded_graph_model = decode_json_model(json_file_path=\"path/to/input.json\", base_uri=\"https://myuri.org#\",\n language=\"en\",\n correct=True)\n```\n\n#### save_graph_file\n\nThe `save_graph_file` utility function provides a convenient way to save an OntoUML graph as an RDF file in the desired syntax.\n\n```python\nfrom json2graph.library import save_graph_file\n\noutput_file_path = \"./output_graph.ttl\"\nsyntax = \"ttl\" # Choose the desired syntax: \"xml\", \"n3\", \"nt\", etc.\nsave_graph_file(ontouml_graph, output_file_path, syntax)\n```\n\nThe valid syntax options are the ones that [can be parsed by the RDFLib](https://rdflib.readthedocs.io/en/stable/intro_to_parsing.html#saving-rdf): turtle, ttl, turtle2, xml, pretty-xml, json-ld, ntriples, nt, nt11, n3, trig, trix, and nquads.\n\n### Input and Output\n\nThis software's **input\n** is a JSON file that complies with the [OntoUML Schema](https://w3id.org/ontouml/schema). This JSON file can be obtained from the [ontouml-vp-plugin](https://w3id.org/ontouml/vp-plugin)'s export feature. The JSON2Graph Decoder was tested to guarantee its compatibility with the JSON generated by the plugin's [version 0.5.3](https://w3id.org/ontouml/vp-plugin/v0.5.3).\n\nThe transformation's **output\n** corresponds to the OntoUML Model serialized as a graph. The saved file information is described by the [OntoUML Vocabulary](https://w3id.org/ontouml/vocabulary) and can be saved in the [different formats that are supported by the RDFLib](https://rdflib.readthedocs.io/en/stable/intro_to_parsing.html#saving-rdf).\nThis output graph may contain the model's diagrammatic information or not, depending on the user's provided arguments.\nThe [OntoUML Vocabulary documentation](https://dev.ontouml.org/ontouml-vocabulary/#mozTocId376551) contains a usage overview, presenting information about all available elements, and about how to use them, including examples of SPARQL queries.\n\nBoth the input and output of the software are built upon the same metamodel, the [OntoUML Metamodel](https://w3id.org/ontouml/metamodel), which facilitates the conversion between different representations.\n\n### OntoUML Vocabulary and gUFO\n\nThe ontouml-vp-plugin has a feature that enables an ontology to be transformed from OntoUML to a graph format. This feature is called the [Model Transformation to OWL with gUFO](https://github.com/OntoUML/ontouml-vp-plugin/#model-transformation-to-owl-with-gufo).\n**[gUFO](https://nemo-ufes.github.io/gufo/)** is a lightweight implementation of the OntoUML's underlying foundational ontology, the Unified Foundational\nOntology (UFO).\n\nEven though an ontology represented in gUFO and in the OntoUML Vocabulary are both suitable for Semantic Web OWL 2 DL applications, these two representations are different and were created with different purposes.\n\ngUFO is intended for reuse in the definition of UFO-based lightweight ontologies. Reuse of gUFO consists in instantiating and/or specializing the various entities defined in the ontology, inheriting from it the domain-independent distinctions of UFO. A key feature of UFO (and hence, gUFO) is that it includes two taxonomies: one with classes whose instances are individuals (classes in this taxonomy include gufo:Object, gufo:Event) and another with classes whose instances are types (classes in this taxonomy include gufo:Kind, gufo:Phase, gufo:Category).\n\nDifferently, the OntoUML Vocabulary was created to support the serialization, exchange, publishing of OntoUML as linked data, and to be used in Semantic Web applications. Models in this format are machine-readable resources intended to support the needs of tool developers and researchers, enabling the performance of complex analysis using the SPARQL querying language with no need for additional software. In addition, as it contains the concrete elements (i.e., diagrammatic data such as diagrams and diagram elements) of OntoUML projects, it can also be used to fully reconstruct the original models.\n\n## Basic Syntactical and Sematic Validation\n\n- Class validations:\n - Reports Class with incompatible attributes isExtensional (not 'null') and isPowertype (set as 'True').\n - Sets Class stereotype as 'collective' when the Class's stereotype is 'null' and its isExtensional attribute is 'True'.\n - Sets Class stereotype as 'type' when the Class's stereotype is 'null' and its isPowertype attribute is 'True'.\n - Removes the Class's isExtensional attribute if the Class's stereotype is not 'collective'.\n - Sets the Class's isPowertype attribute as 'False' if the Class's stereotype is not 'type'.\n - Sets the Class's order attribute to '1' if the Class's stereotype is not 'type' and its order different from '1'.\n - Sets the Class's order attribute to '2' if the Class's stereotype is 'type' and its order is '1'.\n - Reports mandatory Class stereotype missing.\n- Stereotype validations:\n - Reports invalid Class stereotype assigned (i.e., assigned stereotype is not in enumeration class ClassStereotype).\n - Reports invalid Relation stereotype assigned (i.e., assigned stereotype is not in enumeration class RelationStereotype).\n - Reports invalid Property stereotype assigned (i.e., assigned stereotype is not in enumeration class\n PropertyStereotype).\n- Property validations:\n - Reports invalid assertion when a Property stereotype is related to a Class that is known not to be of stereotype 'event'.\n - Sets Class stereotype as 'event' when it is originally 'null' and the class is related to a Property with stereotype.\n\n## Permanent URLs and Identifiers\n\n- Repository: [https://w3id.org/ontouml/json2graph](https://w3id.org/ontouml/json2graph)\n- Documentation: [https://w3id.org/ontouml/json2graph/docs](https://w3id.org/ontouml/json2graph/docs)\n- Releases:\n - All releases: [https://w3id.org/ontouml/json2graph/releases](https://w3id.org/ontouml/json2graph/releases)\n - Latest release: [https://w3id.org/ontouml/json2graph/latest](https://w3id.org/ontouml/json2graph/latest)\n - Specific release: https://w3id.org/ontouml/json2graph/v<n>, where \\<n\\> represents the version number (e.g., '1.0.0')\n\n## Related Projects\n\n- **[OntoUML Metamodel](https://w3id.org/ontouml/metamodel)**:\n Implementation-independent OntoUML Metamodel. Unlike the UML profile, this version is independent of UML and presents only the concepts officially supported in the language. This metamodel covers the abstract and concrete syntaxes of the language and serves as the reference for all projects in the [OntoUML as a Service (OaaS)](https://ceur-ws.org/Vol-2969/paper29-FOMI.pdf) ecosystem, including its different model serializations.\n\n\n- **[OntoUML Vocabulary](https://w3id.org/ontouml/vocabulary)**:\n An OntoUML Metamodel's serialization in Turtle (ttl) format. This vocabulary supports the serialization, exchange, and publishing of OntoUML models as graphs that can be used for Semantic Web and Linked Data applications.\n\n\n- **[OntoUML Schema](https://w3id.org/ontouml/schema)**:\n An OntoUML Metamodel's serialization in JSON format. The JSON is a format better suited for manipulation within software code. It supports the exchange of models between modeling tools and the OntoUML server, providing model intelligent services.\n\n\n- **[ontouml-vp-plugin](https://w3id.org/ontouml/vp-plugin)**:\n The OntoUML Plugin for Visual Paradigm adds features designed for OntoUML modelers to any version of the Visual Paradigm - a modeling editor that provides a [free for non-commercial version](https://www.visual-paradigm.com/download/community.jsp).\n These features range from enabling OntoUML stereotypes in class diagrams to model verification and transformation.\n\n## Development Contribution\n\nWe encourage you to contribute to the development of this software.\n\nThe dependencies to develop this software are not the same as the ones to execute it. Hence, it is necessary run the following command on the terminal inside the project's folder to install all necessary dependencies:\n\n```text\npip install -r requirements.txt\n```\n\nYou also need run `pre-commit install` to set up the git hook scripts.\n\nThe ontouml-json2graph package was developed using test-driven-based development. Multiple tests are available inside the following folder: `ontouml-json2graph/json2graph/tests`. To execute the tests, run the following command from inside the project's root folder:\n\n```text\npytest .\\json2graph\\tests\\test_main.py\n```\n\nThe tests' code documentation [is also available](https://dev.ontouml.org/ontouml-json2graph/autoapi/json2graph/tests/index.html).\n\n## Author\n\nThis project is maintained by the [Semantics, Cybersecurity & Services (SCS) Group](https://www.utwente.nl/en/eemcs/scs/) of the [University of Twente](https://www.utwente.nl/), The Netherlands. Its developer is:\n\n- [Pedro Paulo Favato Barcelos](https://orcid.org/0000-0003-2736-7817) [[GitHub](https://github.com/pedropaulofb)] [[LinkedIn](https://www.linkedin.com/in/pedro-paulo-favato-barcelos/)]\n\nFeel free to get in touch using the provided links. For questions, contributions, or to report any problem, you can **[open an issue](https://github.com/OntoUML/ontouml-json2graph/issues)** at this repository.\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "OntoUML JSON2Graph Decoder",
"version": "1.3.2",
"project_urls": {
"Documentation": "https://w3id.org/ontouml/json2graph/docs",
"Homepage": "https://w3id.org/ontouml/json2graph",
"PyPi Project": "https://pypi.org/project/ontouml-json2graph/",
"Repository": "https://w3id.org/ontouml/json2graph"
},
"split_keywords": [
"semantic-web",
"knowledge-graph",
"ontouml",
"ontology-driven-development",
"ontouml-schema",
"ontouml-vocabulary",
"ontouml-metamodel"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "360e2879adfaea041accc1cf45736afb2a02b0ef8a28ff40b88f28561e2fb78b",
"md5": "10626769d30a2922652f76a5a3344a92",
"sha256": "cf8516c10036ee880cd51ec85e7d3fe17811783d63df9e382820aeea2a8b8069"
},
"downloads": -1,
"filename": "ontouml_json2graph-1.3.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "10626769d30a2922652f76a5a3344a92",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9,<4.0",
"size": 210627,
"upload_time": "2023-09-21T16:28:34",
"upload_time_iso_8601": "2023-09-21T16:28:34.613449Z",
"url": "https://files.pythonhosted.org/packages/36/0e/2879adfaea041accc1cf45736afb2a02b0ef8a28ff40b88f28561e2fb78b/ontouml_json2graph-1.3.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "b2400f0985b55a0ef8a536cdabfffc33c11481135e1b59dffe34886f7807ced2",
"md5": "1d493cddd5d838011090472a513addc4",
"sha256": "8077f0cb83b49f25be91dd75afb5d2bd70127924a6bb1db997998ba8bc6eef85"
},
"downloads": -1,
"filename": "ontouml_json2graph-1.3.2.tar.gz",
"has_sig": false,
"md5_digest": "1d493cddd5d838011090472a513addc4",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9,<4.0",
"size": 195278,
"upload_time": "2023-09-21T16:28:36",
"upload_time_iso_8601": "2023-09-21T16:28:36.291659Z",
"url": "https://files.pythonhosted.org/packages/b2/40/0f0985b55a0ef8a536cdabfffc33c11481135e1b59dffe34886f7807ced2/ontouml_json2graph-1.3.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-09-21 16:28:36",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "ontouml-json2graph"
}