Package: ontouml_vocabulary_lib
ontouml-vocabulary-lib📦 PyPI Package:The library is convenientlyavailable as a PyPI package, allowing users to easily import it into other RDFLib/Python projects.📚 Documentation:For inquiries and further information, please refer to thecomprehensive docstring-generated documentationavailable for this project.Contentsontouml-vocabulary-libContentsInstallation and UsePrerequisitesInstructions for UsersInstructions for ContributorsTechnological BackgroundThe OntoUML VocabularyThe RDFLibConceptsOntoUML TermsMethodsUsage ExamplesOntoUML ConstantsUsage ExamplesCode TestingHow to ContributeReporting IssuesCode ContributionsTest ContributionsGeneral GuidelinesLicenseAuthorInstallation and UsePrerequisitesEnsure you have Python installed on your system before utilizing theontouml-vocabulary-lib. It has been tested with Python versions 3.9 to 3.11 on Mac, Windows, and Linux. If not installed,download and install Python.Instructions for UsersInstall ontouml-vocabulary-lib: Execute the following command to install the library:pipinstallontouml-vocabulary-libAll dependencies will be installed automatically.Usage: To use ontouml-vocabulary-lib, you simply have to make the following import in your Python code:fromontouml_vocabulary_libimport*Now all conceptsInstructions for ContributorsFork the Project:Fork theontouml-vocabulary-librepository to your own GitHub account.Clone and Setup:Clone your forked repository and navigate to the project directory.Install Dependencies:UsePoetryfor dependency management. If not installed, refer to Poetry’sdocumentationfor installation instructions. Then, install all dependencies with:poetryinstallNow, you're ready to make enhancements or fixes and contribute back to ontouml-vocabulary-lib!Technological BackgroundTheontouml-vocabulary-libis a Python library tailored for managing OntoUML concepts onRDFLibgraphs.The library complies with theOntoUML vocabulary—ensuring compatibility with itsversion 1.1.0.The OntoUML VocabularyOntoUML is a modeling language that has been developed to support the representation of domain ontologies in the conceptual modeling phase of system development. TheOntoUML Vocabulary, on the other hand, is an OWL vocabulary designed to allow the serialization and exchanging of OntoUML models in conformance with theOntoUML Metamodel.The OntoUML Vocabulary provides the necessary resources for mapping OntoUML models to OWL ontologies, which is a crucial step for utilizing OntoUML in Semantic Web applications.The RDFLibRDFLibis a Python library that provides a comprehensive toolkit for working withResource Description Framework (RDF)data, which is fundamental to the Semantic Web and linked data technologies. RDFLib enables developers to create, manipulate, and query RDF graphs, making it a powerful tool for managing knowledge graphs within the Python ecosystem.ConceptsWhen working with the ontouml-vocabulary-lib library, users will primarily engage with five fundamental concepts, each contributing to the seamless manipulation of OntoUML models and RDF graphs. These key concepts include OUTerm, which represents OntoUML terms and ensures semantic consistency; OUElement, serving as a container for various OntoUML model elements and maintaining their structured details; OUGraph, a pivotal orchestrator for OntoUML vocabulary elements within RDF graphs, enabling systematic access and manipulation; OUEnumeration, which provides organized enumerations for OntoUML concepts and stereotypes; and Graph, a core concept from RDFLib, offering a structured framework for managing RDF data. Together, these concepts empower users to efficiently handle OntoUML models, navigate their semantic complexities, and interact with RDF graphs, making ontouml-vocabulary-lib a valuable tool for ontology-driven conceptual modeling and semantic web technologies.OntoUML TermsTheOntoUMLclass in this library encapsulates the OntoUML vocabulary, enabling easy interaction with ontological terms to enhance the accuracy and consistency of your model. This class is designed to operate similarly to how RDFLib handles vocabularies like OWL, RDF, and RDFS. In RDFLib, you can access concepts from these vocabularies directly, for instance,RDFS.subClassOforRDF.type(for more information,access here). Similarly, with this library, you can access OntoUML terms directly, e.g.,OntoUML.kind.Additionally, this library integrates theURIRefconcept from RDFLib, which allows for the clear and unambiguous definition of relationships and properties through universal resource identifiers (URIs). AURIRef in RDFLibis a unique identifier used to identify resources in semantic web technologies.MethodsHere are the methods provided by theOntoUMLclass:get_list_all: Retrieves all OntoUML terms as a list ofURIRefobjects.get_namespace: Returns the OntoUML namespace as a string.get_term: Given a term name as a string, retrieves the corresponding OntoUML term as aURIRef.Method NameDescriptionArgumentsReturn Typeget_list_allLists all OntoUML termsNoneList ofURIRefget_namespaceGets OntoUML namespaceNonestrget_termGets a specific OntoUML termterm_name: strURIRefor ErrorUsage ExamplesBelow are some practical examples illustrating how to utilize the OntoUML Terms concept.Accessing a specific OntoUML Term:# Accessing a specific OntoUML termfromontouml_vocabulary_libimportOntoUMLmy_ontouml_class=OntoUML.Class# Outputprint(my_ontouml_class)# https://w3id.org/ontouml#ClassThe result "https://w3id.org/ontouml#Class" from box 1 is oftype URIRef in RDFLib, which represents a Uniform Resource Identifier (URI) within the Resource Description Framework (RDF) data model, serving as a unique identifier for resources in semantic web technologies.Accessing all OntoUML Terms# Accessing all OntoUML termsfromontouml_vocabulary_libimportOntoUMLall_terms=OntoUML.get_list_all()# Outputprint(all_terms)# [rdflib.term.URIRef('https://w3id.org/ontouml#abstract'), rdflib.term.URIRef('https://w3id.org/ontouml#abstractNature'), rdflib.term.URIRef('https://w3id.org/ontouml#aggregationKind'), ...]As can be seen, the result is a list of URIRefs.Accessing the OntoUML Vocabulary base namespaceTheget_namespacemethod is used to retrieve the namespace URI for OntoUML Vocabulary. Here is an example demonstrating how to use this method:# Getting the namespace for OntoUMLfromontouml_vocabulary_libimportOntoUMLnamespace_uri=OntoUML.get_namespace()# Outputprint(namespace_uri)# https://w3id.org/ontouml#These methods ease the process of working with OntoUML terms, making it intuitive to use them within your projects.OntoUML ConstantsTheontouml-vocabulary-liblibrary includes a set of predefined constants that group OntoUML stereotypes into semantically relevant categories, allowing for a structured approach to accessing and utilizing OntoUML concepts in your Python programs. These constants are organized into tuples with alphabetically sorted elements. Each tuple represents a different categorization of OntoUML stereotypes.Class Stereotypes:Base Sortal Class Stereotypes:ONTOUML_BASE_SORTAL_CLASS_STEREOTYPESUltimate Sortal Class Stereotypes:ONTOUML_ULTIMATE_SORTAL_CLASS_STEREOTYPESSortal Class Stereotypes:ONTOUML_SORTAL_CLASS_STEREOTYPESNon-Sortal Class Stereotypes:ONTOUML_NON_SORTAL_CLASS_STEREOTYPESAbstract Class Stereotypes:ONTOUML_ABSTRACT_CLASS_STEREOTYPESRigid Class Stereotypes:ONTOUML_RIGID_CLASS_STEREOTYPESAnti-Rigid Class Stereotypes:ONTOUML_ANTI_RIGID_CLASS_STEREOTYPESSemi-Rigid Class Stereotypes:ONTOUML_SEMI_RIGID_CLASS_STEREOTYPESAll Class Stereotypes:ONTOUML_CLASS_STEREOTYPESMiscellaneous Stereotypes:Relation Stereotypes:ONTOUML_RELATION_STEREOTYPESProperty Stereotypes:ONTOUML_PROPERTY_STEREOTYPESAggregation Kinds:ONTOUML_AGGREGATION_KINDSOntological Natures:ONTOUML_ONTOLOGICAL_NATURESAbstract Elements:ONTOUML_ABSTRACT_ELEMENTSConcrete Elements:ONTOUML_CONCRETE_ELEMENTSUsage ExamplesBelow are some practical examples illustrating how to utilize the OntoUML Terms concept. In these examples, we are utilizing the*import statement to import all the constants from theconstants_classesandconstants_miscmodules within theontouml_vocabulary_lib.constantssub-package. Ensure you have theontouml-vocabulary-liblibrary installed and accessible in your environment.Listing All Base Sortal Class Stereotypes:fromontouml_vocabulary_lib.constants.constants_classesimport*# Listing all base sortal class stereotypes# The tuple contains stereotypes that are considered as base sortals in OntoUMLprint(ONTOUML_BASE_SORTAL_CLASS_STEREOTYPES)Output:(rdflib.term.URIRef('https://w3id.org/ontouml#historicalRole'), rdflib.term.URIRef('https://w3id.org/ontouml#phase'), rdflib.term.URIRef('https://w3id.org/ontouml#role'), rdflib.term.URIRef('https://w3id.org/ontouml#subkind'))Validating an OntoUML Concept against a Set of Stereotypes:fromontouml_vocabulary_lib.constants.constants_classesimport*fromontouml_vocabulary_lib.termsimportOntoUML# A given OntoUML Concept (Assume OntoUML.kind is of type URIRef)given_ontouml_concept=OntoUML.kind# Validate if it's a base sortal# Checking if the given OntoUML concept is part of the base sortal class stereotypesis_base_sortal=given_ontouml_conceptinONTOUML_BASE_SORTAL_CLASS_STEREOTYPES# Output the validation resultprint(f"Is{given_ontouml_concept}a base sortal stereotype?")print("Yes"ifis_base_sortalelse"No")Output:Is https://w3id.org/ontouml#kind a base sortal stereotype?
NoComparing Values between Different Sets of Stereotypes:fromontouml_vocabulary_lib.constants.constants_classesimport*# Retrieve all ultimate sortals and rigid typesall_ultimate_sortal_classes=ONTOUML_ULTIMATE_SORTAL_CLASS_STEREOTYPESall_rigid_types=ONTOUML_RIGID_CLASS_STEREOTYPES# Find common stereotypes between both, if any# Using set intersection to find common elements between the two tuplescommon_stereotypes=set(all_ultimate_sortal_classes).intersection(set(all_rigid_types))# Output common stereotypesprint("Common stereotypes between Ultimate Sortals and Rigid types:")print(common_stereotypes)Output:Common stereotypes between Ultimate Sortals and Rigid types:
{rdflib.term.URIRef('https://w3id.org/ontouml#quality'), rdflib.term.URIRef('https://w3id.org/ontouml#collective'), rdflib.term.URIRef('https://w3id.org/ontouml#relator'), rdflib.term.URIRef('https://w3id.org/ontouml#kind'), rdflib.term.URIRef('https://w3id.org/ontouml#quantity'), rdflib.term.URIRef('https://w3id.org/ontouml#mode')}Code TestingThe code provided has undergone rigorous testing to ensure its reliability and correctness. The tests can be found in the 'tests' directory of the project. To run the tests, navigate to the project root directory and execute the following command:ontouml-vocabulary-lib>pytest.\ontouml_vocabulary_lib\testsHow to ContributeReporting IssuesIf you encounter a bug or wish to suggest a feature, pleaseopen a new issue.If you notice any discrepancies in the documentation created with the aid of AI, feel free toreport them by opening an issue.Code ContributionsFork the project repository and create a new feature branch for your work:git checkout -b feature/YourFeatureName.Make and commit your changes with descriptive commit messages.Push your work back up to your fork:git push origin feature/YourFeatureName.Submit a pull request to propose merging your feature branch into the main project repository.Test ContributionsEnhance the project's reliability by adding new tests or improving existing ones.General GuidelinesEnsure your code follows our coding standards.Update the documentation as necessary.Make sure your contributions do not introduce new issues.We appreciate your time and expertise in contributing to this project!LicenseThis project is licensed under the Apache License 2.0. See theLICENSEfile for details.AuthorThis project is an initiative of theSemantics, Cybersecurity & Services (SCS) Groupat theUniversity of Twente, The Netherlands. The main developer is:Pedro Paulo Favato Barcelos [GitHub] [LinkedIn]Feel free to reach out using the provided links. For inquiries, contributions, or to report any issues, you canopen a new issueon this repository.