json2graph.modules.utils_graph
Util functions related to graphs.
Module Contents
Functions
|
Receives the name of the OntoUML Vocabulary's entity as a string and returns the corresponding URIRef. |
Loads the OntoUML Vocabulary to the working memory. First tries to load from web resource, if fails, it tries to |
|
|
Safely load graph from file to working memory using arguments provided by the user, which are the file path |
|
Queries the graph for all elements of the given element_type and returns a list of their ids. |
Attributes
- json2graph.modules.utils_graph.LOGGER
- json2graph.modules.utils_graph.ontouml_ref(entity)
Receives the name of the OntoUML Vocabulary’s entity as a string and returns the corresponding URIRef.
- Parameters:
entity (str) – OntoUML Vocabulary entity (class, property, or individual) to have its URIRef returned.
- Returns:
URIRef of the informed OntoUML Vocabulary’s entity.
- Return type:
URIRef
- json2graph.modules.utils_graph.load_ontouml_vocabulary()
Loads the OntoUML Vocabulary to the working memory. First tries to load from web resource, if fails, it tries to load form the local resource. If both options fail, calls error reporting function.
- Returns:
RDFLib graph loaded as object.
- Return type:
Graph
- json2graph.modules.utils_graph.load_graph_safely(ontology_file, format='not_provided')
Safely load graph from file to working memory using arguments provided by the user, which are the file path and (optionally) the file type.
- Parameters:
ontology_file (str) – Path to the ontology file to be loaded into the working memory.
format (str) – Optional argument. Format of the file to be loaded.
- Returns:
RDFLib graph loaded as object.
- Return type:
Graph
- json2graph.modules.utils_graph.get_all_ids_for_type(ontology_graph, element_type)
Queries the graph for all elements of the given element_type and returns a list of their ids.
- Parameters:
ontology_file (Graph) – Loaded ontology graph.
element_type (list[str]) – Type of the element (originally a JSON object) to be queried to have their ids returned .
ontology_graph (rdflib.Graph) –
- Return type:
list[str]