Parser
VoID (Vocabulary of Interlinked Datasets) Parser.
Parses an in-memory VoID RDF graph and converts the embedded schema to various downstream formats (JSON-LD, LinkML, SHACL, RDF-config, DataFrame).
It also serves as the entry-point for discovering VoID catalogs at
live SPARQL endpoints (discover_void_graphs) and for turning raw
partition records back into an RDF graph
(build_void_graph_from_partitions).
- class VoidParser(void_source: str | Graph | None = None, graph_uris: str | list[str] | None = None, exclude_graphs: bool = True)[source]
Bases:
objectParser for VoID (Vocabulary of Interlinked Datasets) files.
Initialize the VoID parser.
- Parameters:
void_source – File path (str) or RDF Graph object
graph_uris – Graph URI(s) to analyze, or None for all non-system graphs
exclude_graphs – Exclude Virtuoso system graphs
- to_jsonld(filter_void_admin_nodes: bool = True, endpoint_url: str | None = None, dataset_name: str | None = None, graph_uris: list[str] | None = None) dict[str, Any][source]
Parse VoID file and return simple JSON-LD with the schema triples.
- Parameters:
filter_void_admin_nodes – Whether to filter out VoID-specific nodes
endpoint_url – SPARQL endpoint URL for the @about section
dataset_name – Dataset name for the @about section
graph_uris – Graph URIs for the @about section
- Returns:
Simple JSON-LD with @context, @graph, and @about sections
- to_schema(filter_void_admin_nodes: bool = True) DataFrame[source]
Parse VoID file and return schema as pandas DataFrame. This method now uses the JSON-LD generation as the source of truth.
- Parameters:
filter_void_admin_nodes – Whether to filter out VoID-specific nodes
- Returns:
DataFrame with schema information including CURIEs
- to_linkml(filter_void_nodes: bool = True, schema_name: str | None = None, schema_description: str | None = None, schema_base_uri: str | None = None, jsonld_override: dict[str, Any] | None = None) SchemaDefinition[source]
Generate LinkML schema from JSON-LD representation.
See
rdfsolve.schema_models.linkml.to_linkml()for full documentation.
- to_linkml_yaml(filter_void_nodes: bool = True, schema_name: str | None = None, schema_description: str | None = None, schema_base_uri: str | None = None) str[source]
Return LinkML schema as YAML string.
- to_shacl(filter_void_nodes: bool = True, schema_name: str | None = None, schema_description: str | None = None, schema_base_uri: str | None = None, closed: bool = True, suffix: str | None = None, include_annotations: bool = False) str[source]
Generate SHACL shapes from VoID schema.
- to_rdfconfig(filter_void_nodes: bool = True, endpoint_url: str | None = None, endpoint_name: str | None = None, graph_uri: str | None = None) dict[str, str][source]
Generate RDF-config YAML files.
- discover_void_graphs(endpoint_url: str) dict[str, Any][source]
Discover VoID graphs at endpoint_url via a SELECT query.
Queries for VoID partitions across all named graphs. Returns a dict describing found graphs and their raw partition records, which can be passed directly to
build_void_graph_from_partitions().- Parameters:
endpoint_url – SPARQL endpoint URL.
- Returns:
Dict with keys
has_void_descriptions,found_graphs,total_graphs,void_content,partitions. On failure anerrorkey is added and counts are zero.
- build_void_graph_from_partitions(partitions: list[dict[str, str]], base_uri: str | None = None) Graph[source]
Convert raw partition records into an RDF VoID graph.
Partition records are the dicts produced by
discover_void_graphs()(keys:subjectClass,prop, optionallyobjectClass/objectDatatype).- Parameters:
partitions – Partition records from
discover_void_graphs().base_uri – Base URI for generated blank-node-replacement IRIs.
- Returns:
RDF
Graphwith VoID partition triples.