Skip to content

ontocast.onto.scaffolding

The nodes OntoCast mints around extracted facts.

The pipeline records where each fact came from with standard vocabulary: content-unit (chunk) nodes typed prov:Entity and schema:Text, and one reifier per asserted triple (rdf:reifies in RDF 1.2, rdf:Statement in the classic export) pointing at its chunks with prov:wasDerivedFrom.

Scaffolding is identified by these nodes, never by namespace: a facts graph may use PROV-O, schema.org or Dublin Core as domain vocabulary, and those triples are facts like any other. The document node is not scaffolding: its title, date and source are facts about the document.

Attributes

__all__ = ['chunk_nodes', 'document_nodes', 'is_scaffolding', 'reifier_nodes', 'scaffolding_nodes'] module-attribute

Functions:

chunk_nodes(graph)

Content-unit nodes: typed both prov:Entity and schema:Text.

Source code in ontocast/onto/scaffolding.py
def chunk_nodes(graph: Graph) -> set[Node]:
    """Content-unit nodes: typed both ``prov:Entity`` and ``schema:Text``."""
    entities = set(graph.subjects(RDF.type, PROV.Entity))
    return {
        node
        for node in entities
        if any(str(t) in _SCHEMA_TEXT for t in graph.objects(node, RDF.type))
    }

document_nodes(graph)

The document node the pipeline mints: typed prov:Entity and foaf:Document.

Source code in ontocast/onto/scaffolding.py
def document_nodes(graph: Graph) -> set[Node]:
    """The document node the pipeline mints: typed ``prov:Entity`` and ``foaf:Document``."""
    return set(graph.subjects(RDF.type, PROV.Entity)) & set(
        graph.subjects(RDF.type, FOAF.Document)
    )

is_scaffolding(triple, nodes)

True when triple describes, or points at, a scaffolding node.

Parameters:

Name Type Description Default
triple tuple[Node, Node, Node]

An (s, p, o) triple.

required
nodes set[Node]

:func:scaffolding_nodes of the graph the triple belongs to.

required
Source code in ontocast/onto/scaffolding.py
def is_scaffolding(triple: tuple[Node, Node, Node], nodes: set[Node]) -> bool:
    """True when ``triple`` describes, or points at, a scaffolding node.

    Args:
        triple: An ``(s, p, o)`` triple.
        nodes: :func:`scaffolding_nodes` of the graph the triple belongs to.
    """
    subject, _, obj = triple
    return subject in nodes or obj in nodes

reifier_nodes(graph)

Statement reifiers, in either provenance profile.

Source code in ontocast/onto/scaffolding.py
def reifier_nodes(graph: Graph) -> set[Node]:
    """Statement reifiers, in either provenance profile."""
    return set(graph.subjects(RDF_REIFIES, None)) | set(
        graph.subjects(RDF.type, RDF.Statement)
    )

scaffolding_nodes(graph)

Chunk nodes and reifiers: the bookkeeping that carries no fact.

Source code in ontocast/onto/scaffolding.py
def scaffolding_nodes(graph: Graph) -> set[Node]:
    """Chunk nodes and reifiers: the bookkeeping that carries no fact."""
    return chunk_nodes(graph) | reifier_nodes(graph)