SOLI Graph Module#
The soli.graph module provides the main functionality for working with the SOLI (Standard for Open Legal Information) ontology. It contains the SOLI class, which is responsible for loading, parsing, and querying the ontology.
Module Contents#
soli/graph.py - SOLI (Standard for Open Legal Information) Python library
https://openlegalstandard.org/
This module provides a Python library for working with SOLI (Standard for Open Legal Information) data.
- class soli.graph.SOLI(source_type: str = 'github', http_url: str | None = None, github_repo_owner: str = 'alea-institute', github_repo_name: str = 'soli', github_repo_branch: str = '1.0.0', use_cache: bool = True)#
SOLI (Standard for Open Legal Information) Python library
This class provides a Python library for working with SOLI (Standard for Open Legal Information) data.
- generate_iri() str#
Generate a new IRI for the SOLI ontology.
NOTE: This is designed to approximate the WebProtege IRI generation algorithm.
- Returns:
str: The new IRI.
- get_areas_of_law(max_depth: int = 16) List[OWLClass]#
Get the areas of law in the SOLI ontology.
- Returns:
List[OWLClass]: The list of areas of law.
- get_asset_types(max_depth: int = 16) List[OWLClass]#
Get the asset types in the SOLI ontology.
- Returns:
List[OWLClass]: The list of asset types.
- get_by_alt_label(alt_label: str, include_hidden_labels: bool = True) List[OWLClass]#
Get an OWL class by alternative label.
- Args:
alt_label (str): The alternative label of the OWL class. include_hidden_labels (bool): Whether to include hidden labels.
- Returns:
List[OWLClass]: The list of OWL classes with the given alternative label.
- get_by_label(label: str, include_alt_labels: bool = False) List[OWLClass]#
Get an OWL class by label.
- Args:
label (str): The label of the OWL class. include_alt_labels (bool): Whether to include alternative labels.
- Returns:
List[OWLClass]: The list of OWL classes with the given label.
- get_children(iri: str, max_depth: int = 16) List[OWLClass]#
Get the children of an OWL class in the SOLI ontology.
- Args:
iri (str): The IRI of the OWL class to start from. max_depth (int): The maximum depth to traverse the graph.
- Returns:
List[OWLClass]: The children of the OWL class.
- get_communication_modalities(max_depth: int = 16) List[OWLClass]#
Get the communication modalities in the SOLI ontology.
- Returns:
List[OWLClass]: The list of communication modalities.
- get_currencies(max_depth: int = 16) List[OWLClass]#
Get the currencies in the SOLI ontology.
- Returns:
List[OWLClass]: The list of currencies.
- get_data_formats(max_depth: int = 16) List[OWLClass]#
Get the data formats in the SOLI ontology.
- Returns:
List[OWLClass]: The list of data formats.
- get_document_artifacts(max_depth: int = 16) List[OWLClass]#
Get the document artifacts in the SOLI ontology.
- Returns:
List[OWLClass]: The list of document artifacts.
- get_engagement_terms(max_depth: int = 16) List[OWLClass]#
Get the engagement terms in the SOLI ontology.
- Returns:
List[OWLClass]: The list of engagement terms.
- get_events(max_depth: int = 16) List[OWLClass]#
Get the events in the SOLI ontology.
- Returns:
List[OWLClass]: The list of events.
- get_forum_venues(max_depth: int = 16) List[OWLClass]#
Get the forum venues in the SOLI ontology.
- Returns:
List[OWLClass]: The list of forum venues.
- get_governmental_bodies(max_depth: int = 16) List[OWLClass]#
Get the governmental bodies in the SOLI ontology.
- Returns:
List[OWLClass]: The list of governmental bodies.
- get_industries(max_depth: int = 16) List[OWLClass]#
Get the industries in the SOLI ontology.
- Returns:
List[OWLClass]: The list of industries.
- get_languages(max_depth: int = 16) List[OWLClass]#
Get the languages in the SOLI ontology.
- Returns:
List[OWLClass]: The list of languages.
- get_legal_authorities(max_depth: int = 16) List[OWLClass]#
Get the legal authorities in the SOLI ontology.
- Returns:
List[OWLClass]: The list of legal authorities.
- get_legal_entities(max_depth: int = 16) List[OWLClass]#
Get the legal entities in the SOLI ontology.
- Returns:
List[OWLClass]: The list of legal entities.
- get_locations(max_depth: int = 16) List[OWLClass]#
Get the locations in the SOLI ontology.
- Returns:
List[OWLClass]: The list of locations.
- get_matter_narrative_formats(max_depth: int = 16) List[OWLClass]#
Get the matter narrative formats in the SOLI ontology.
- Returns:
List[OWLClass]: The list of matter narrative formats.
- get_matter_narratives(max_depth: int = 16) List[OWLClass]#
Get the matter narratives in the SOLI ontology.
- Returns:
List[OWLClass]: The list of matter narratives.
- static get_ns_tag(ns: str, tag: str) str#
Get the namespace tag for an XML element.
- Args:
ns (str): The namespace. tag (str): The tag name.
- Returns:
str: The namespace tag.
- get_objectives(max_depth: int = 16) List[OWLClass]#
Get the objectives in the SOLI ontology.
- Returns:
List[OWLClass]: The list of objectives.
- get_parents(iri: str, max_depth: int = 16) List[OWLClass]#
Get the parents of an OWL class in the SOLI ontology.
- Args:
iri (str): The IRI of the OWL class to start from. max_depth (int): The maximum depth to traverse the graph.
- Returns:
List[OWLClass]: The parents of the OWL class.
- get_player_actors(max_depth: int = 16) List[OWLClass]#
Get the player actors in the SOLI ontology.
- Returns:
List[OWLClass]: The list of player actors.
- get_services(max_depth: int = 16) List[OWLClass]#
Get the services in the SOLI ontology.
- Returns:
List[OWLClass]: The list of services.
- get_soli_types(max_depth: int = 16) List[OWLClass]#
Get the SOLI types in the SOLI ontology.
- Returns:
List[OWLClass]: The list of SOLI types.
- get_standards_compatibilities(max_depth: int = 16) List[OWLClass]#
Get the standards compatibilities in the SOLI ontology.
- Returns:
List[OWLClass]: The list of standards compatibilities.
- get_statuses(max_depth: int = 16) List[OWLClass]#
Get the statuses in the SOLI ontology.
- Returns:
List[OWLClass]: The list of statuses.
- get_subgraph(iri: str, max_depth: int = 16) List[OWLClass]#
Recursive function to get the subgraph of the SOLI ontology.
- Args:
iri (str): The IRI of the OWL class to start from. max_depth (int): The maximum depth to traverse the graph.
- Returns:
List[OWLClass]: The subgraph of the SOLI ontology.
- get_system_identifiers(max_depth: int = 16) List[OWLClass]#
Get the system identifiers in the SOLI ontology.
- Returns:
List[OWLClass]: The list of system identifiers.
- get_triples_by_object(obj: str) List[Tuple[str, str, str]]#
Get triples by object.
- Args:
obj (str): The object to filter by.
- Returns:
List[Tuple[str, str, str]]: The list of triples.
- get_triples_by_predicate(predicate: str) List[Tuple[str, str, str]]#
Get triples by predicate.
- Args:
predicate (str): The predicate to filter by.
- Returns:
List[Tuple[str, str, str]]: The list of triples.
- get_triples_by_subject(subject: str) List[Tuple[str, str, str]]#
Get triples by subject.
- Args:
subject (str): The subject to filter by.
- Returns:
List[Tuple[str, str, str]]: The list of triples.
- static list_branches(repo_owner: str = 'alea-institute', repo_name: str = 'soli') List[str]#
List the branches in a GitHub repository.
- Args:
repo_owner (str): The owner of the GitHub repository. repo_name (str): The name of the GitHub repository.
- Returns:
List[str]: A list of branch names in the GitHub repository.
- static load_cache(cache_path: str | Path = PosixPath('/home/docs/.soli/cache'), source_type: str = 'github', http_url: str | None = None, github_repo_owner: str = 'alea-institute', github_repo_name: str = 'soli', github_repo_branch: str = '1.0.0') str | None#
Load the SOLI ontology from a local cache.
- Args:
cache_path (str | Path): The path to the cache directory. source_type (str): The source type for loading the ontology. Either “github” or “http”. http_url (Optional[str]): The HTTP URL for the ontology. github_repo_owner (str): The owner of the GitHub repository. github_repo_name (str): The name of the GitHub repository. github_repo_branch (str): The branch of the GitHub repository.
- Returns:
str | None: The raw ontology buffer, or None if the cache file does not exist.
- static load_owl(source_type: str = 'github', http_url: str | None = None, github_repo_owner: str = 'alea-institute', github_repo_name: str = 'soli', github_repo_branch: str = '1.0.0', use_cache: bool = True) str#
Load the SOLI ontology in OWL format.
- Args:
source_type (str): The source type for loading the ontology. Either “github” or “http”. http_url (Optional[str]): The HTTP URL for the ontology. github_repo_owner (str): The owner of the GitHub repository. github_repo_name (str): The name of the GitHub repository. github_repo_branch (str): The branch of the GitHub repository. use_cache (bool): Whether to use the local cache.
- static load_owl_github(repo_owner: str = 'alea-institute', repo_name: str = 'soli', repo_branch: str = '1.0.0') str#
Load the SOLI ontology in OWL format from a GitHub repository.
- Args:
repo_owner (str): The owner of the GitHub repository. repo_name (str): The name of the GitHub repository. repo_branch (str): The branch of the GitHub repository.
- static load_owl_http(http_url: str | None = None) str#
Load the SOLI ontology in OWL format from an HTTP URL.
- Args:
http_url (str): The HTTP URL for the ontology.
- static normalize_iri(iri: str) str#
Normalize an IRI by removing the SOLI prefix or by handling legacy IRIs.
- Args:
iri (str): The IRI to normalize.
- Returns:
str: The normalized IRI.
- parse_node(node: _Element) None#
Parse a node in the SOLI ontology.
- Switch on these types:
owl:Class
owl:ObjectProperty
owl:DatatypeProperty
owl:AnnotationProperty
owl:NamedIndividual
owl:Ontology
rdf:Description
- Args:
node (lxml.etree._Element): The node element.
- Returns:
None
- parse_owl(buffer: str) None#
Parse the SOLI ontology in OWL format.
- Args:
buffer (str): The raw ontology buffer.
- Returns:
lxml.etree.ElementTree: The parsed ontology tree.
- parse_owl_class(node: _Element) None#
Parse an OWL class in the SOLI ontology.
- Args:
node (lxml.etree._Element): The node element.
- Returns:
OWLClass | None: The parsed OWL class, or None if the class is invalid.
- parse_owl_ontology(node: _Element) None#
Parse an OWL ontology in the SOLI ontology.
- Args:
node (lxml.etree._Element): The node element.
- Returns:
None
- refresh() None#
Refresh the SOLI ontology.
- Returns:
None
- static save_cache(buffer: str, cache_path: str | Path = PosixPath('/home/docs/.soli/cache'), source_type: str = 'github', http_url: str | None = None, github_repo_owner: str = 'alea-institute', github_repo_name: str = 'soli', github_repo_branch: str = '1.0.0') None#
Save the SOLI ontology to a local cache.
- Args:
buffer (str): The raw ontology buffer. cache_path (str | Path): The path to the cache directory. source_type (str): The source type for loading the ontology. Either “github” or “http”. http_url (Optional[str]): The HTTP URL for the ontology. github_repo_owner (str): The owner of the GitHub repository. github_repo_name (str): The name of the GitHub repository. github_repo_branch (str): The branch of the GitHub repository.
- search_by_definition(definition: str, limit: int = 10) List[Tuple[OWLClass, int | float]]#
Search for an OWL class by definition.
- Args:
definition (str): The definition to search for. limit (int): The maximum number of results to return.
- Returns:
- List[Tuple[OWLClass, int | float]]: The list of search results with
the OWL class and the search score.
- search_by_label(label: str, include_alt_labels: bool = True, limit: int = 10) List[Tuple[OWLClass, int | float]]#
Search for an OWL class by label.
- Args:
label (str): The label to search for. include_alt_labels (bool): Whether to include alternative labels. limit (int): The maximum number of results to return.
- Returns:
- List[Tuple[OWLClass, int | float]]: The list of search results with
the OWL class and the search score.
- class soli.graph.SOLITypes(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)#
Enum for SOLI types.