cemento.rdf package#
Submodules#
cemento.rdf.drawio_to_turtle module#
- cemento.rdf.drawio_to_turtle.convert_drawio_to_ttl(input_path: str | Path, output_path: str | Path, onto_ref_folder: str | Path, defaults_folder: str | Path, prefixes_path: str | Path, log_substitution_path: str | Path = None) None#
Convert an input draw.io diagram file of an ontology into RDF triples in the turtle format.
- Parameters:
input_path (str | Path) – The path to the draw.io file input.
output_path (str | Path) – The desired file path for saving the RDF triples in the turtle format.
onto_ref_folder (str | Path) – The path to the folder containing the reference ontologies.
defaults_folder (str | Path) – The path to the folder containing the turtle files of the default namespaces.
prefixes_path (str | Path) – The path to the json file containing prefixes.
log_substitution_path (str | Path, optional) – The path to a csv file containing substitution results from term matching. Defaults to None.
- Returns:
None
cemento.rdf.filters module#
- cemento.rdf.filters.term_in_search_results(term: URIRef, inv_prefixes: dict[URIRef | Namespace, str], search_terms: dict[str, URIRef]) URIRef#
- cemento.rdf.filters.term_not_in_default_namespace(term: URIRef, inv_prefixes: dict[URIRef | Namespace, str], default_namespace_prefixes: dict[str, Namespace]) bool#
cemento.rdf.graph_to_turtle module#
- cemento.rdf.graph_to_turtle.convert_graph_to_ttl(graph: DiGraph, output_path: str | Path, onto_ref_folder: str | Path = None, prefixes_path: str | Path = None, log_substitution_path: str | Path = None) None#
cemento.rdf.io module#
- cemento.rdf.io.get_diagram_terms_iter(graph: DiGraph) Iterable[str]#
- cemento.rdf.io.get_diagram_terms_iter_with_pred(graph: DiGraph) Iterable[str, bool]#
- cemento.rdf.io.save_substitute_log(substitution_results: dict[str, tuple[URIRef, Iterable[str], Iterable[str]]], log_substitution_path: str | Path) None#
cemento.rdf.preprocessing module#
- cemento.rdf.preprocessing.clean_literal_string(literal_term: str) str#
- cemento.rdf.preprocessing.format_literal(literal: Literal) str#
- cemento.rdf.preprocessing.get_term_aliases(term: str) list[str]#
- cemento.rdf.preprocessing.remove_suppression_key(term: str) str#
cemento.rdf.transforms module#
- cemento.rdf.transforms.add_domains_ranges(term_domains_ranges: [<class 'rdflib.term.URIRef'>, collections.abc.Iterable[rdflib.term.URIRef], collections.abc.Iterable[rdflib.term.URIRef]], rdf_graph: ~networkx.classes.digraph.DiGraph) Graph#
- cemento.rdf.transforms.add_labels(rdf_graph: Graph, term: URIRef, labels: list[str]) Graph#
- cemento.rdf.transforms.add_rdf_triples(rdf_graph: Graph, triples: Iterable[tuple[URIRef | Literal, URIRef, URIRef | Literal]]) Graph#
- cemento.rdf.transforms.add_triples_to_digraph(subj: URIRef | Literal, pred: URIRef, obj: URIRef | Literal, graph: DiGraph) DiGraph#
- cemento.rdf.transforms.assign_edge_attr(graph: DiGraph, edges: tuple[any, any], new_attrs: dict[str, any]) DiGraph#
- cemento.rdf.transforms.assign_edge_binary_attr(graph: Graph, filter_func: Callable[[dict[str, any]], bool], attr: str)#
- cemento.rdf.transforms.assign_literal_ids(rdf_graph: Graph, literal_replacements: Iterable[tuple[Literal, Literal]]) DiGraph#
- cemento.rdf.transforms.assign_literal_status(graph: DiGraph, all_literals: set[Literal]) DiGraph#
- cemento.rdf.transforms.assign_pred_status(graph: DiGraph) DiGraph#
- cemento.rdf.transforms.assign_rank_status(graph: DiGraph, rank_terms: set[URIRef] = {rdflib.term.URIRef('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), rdflib.term.URIRef('http://www.w3.org/2000/01/rdf-schema#subClassOf')})#
- cemento.rdf.transforms.assign_strat_status(graph: DiGraph, strat_terms: set[URIRef] = {rdflib.term.URIRef('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), rdflib.term.URIRef('http://www.w3.org/2000/01/rdf-schema#subClassOf')}) DiGraph#
- cemento.rdf.transforms.bind_prefixes(rdf_graph: Graph, prefixes: dict[str, URIRef | Namespace]) Graph#
- cemento.rdf.transforms.construct_literal(term: str, lang='en', datatype=None) Literal#
- cemento.rdf.transforms.construct_term_uri(prefix: str, abbrev_term: str, prefixes: dict[str, URIRef | Namespace]) URIRef#
- cemento.rdf.transforms.get_class_terms(graph: DiGraph) set[URIRef]#
- cemento.rdf.transforms.get_domains_ranges(predicate: Iterable[URIRef], graph: DiGraph) tuple[URIRef, Iterable[URIRef], Iterable[URIRef]]#
- cemento.rdf.transforms.get_graph_relabel_mapping(terms: URIRef, all_classes: set[URIRef], all_instances: set[URIRef], aliases: dict[URIRef, Literal], inv_prefix: dict[str, str]) dict[URIRef, str]#
- cemento.rdf.transforms.get_literal_data_type(literal_term: str, search_terms: dict[str, URIRef], score_cutoff=90) URIRef | None#
- cemento.rdf.transforms.get_literal_format_mapping(graph: DiGraph) dict[Literal, str]#
- cemento.rdf.transforms.get_literal_lang_annotation(literal_term: str, default=None) str#
- cemento.rdf.transforms.get_literal_values_with_id(literal_terms: list[Literal]) Iterable[tuple[Literal, Literal]]#
- cemento.rdf.transforms.get_term_collection_triples(rdf_graph: Graph, head_term: Iterable[URIRef], member_terms: Iterable[URIRef], member_rel: URIRef, term_collection_rel: URIRef) list[tuple[URIRef, URIRef, URIRef]]#
- cemento.rdf.transforms.get_term_domain(term: URIRef, graph: DiGraph) Iterable[URIRef]#
- cemento.rdf.transforms.get_term_range(term: URIRef, graph: DiGraph) Iterable[URIRef]#
- cemento.rdf.transforms.get_term_value(subj: URIRef, pred: URIRef, ref_rdf_graph: Graph)#
- cemento.rdf.transforms.get_uuid()#
- cemento.rdf.transforms.get_xsd_terms() dict[str, URIRef]#
- cemento.rdf.transforms.rename_edges(graph: DiGraph, rename_mapping: dict[URIRef, str]) DiGraph#
cemento.rdf.turtle_to_drawio module#
- cemento.rdf.turtle_to_drawio.convert_ttl_to_drawio(input_path: str | Path, output_path: str | Path, horizontal_tree: bool = False, classes_only: bool = False, onto_ref_folder: str | Path = None, defaults_folder: str | Path = None, prefixes_path: str | Path = None, set_unique_literals: bool = True) None#
Convert RDF triples in the turtle format as an ontology diagram in a draw.io file.
- Parameters:
input_path (str | Path) – The path to the turtle input file.
output_path (str | Path) – The desired file path for saving an ontology diagram as a draw.io file.
horizontal_tree (bool, optional) – Whether to make the tree horizontal or stay with the default vertical layout. Defaults to False.
classes_only (bool, optional) – Whether to just display classes and instances (taxonomy tree). Defaults to False.
onto_ref_folder (str | Path, optional) – The path to the folder containing the reference ontologies. Defaults to None.
defaults_folder (str | Path, optional) – The path to the folder containing the turtle files of the default namespaces. Defaults to None.
prefixes_path (str | Path, optional) – The path to the json file containing prefixes. Defaults to None.
log_substitution_path (str | Path, optional) – The path to a csv file containing substitution results from term matching. Defaults to None.
- Returns:
None
cemento.rdf.turtle_to_graph module#
- cemento.rdf.turtle_to_graph.convert_ttl_to_graph(input_path: str | Path, classes_only: bool = False, onto_ref_folder: str | Path = None, defaults_folder: str | Path = None, prefixes_path: str | Path = None, set_unique_literals=True) DiGraph#