ontocast.onto.reification¶
RDF 1.2 statements about statements, held beside an rdflib graph.
Provenance is RDF 1.2 reification: _:r rdf:reifies <<( s p o )>> plus
_:r prov:wasDerivedFrom <chunk>. rdflib has no node type for a triple term,
so an :class:~ontocast.onto.rdfgraph.RDFGraph keeps every rdf:reifies
statement here, in a pyoxigraph Dataset, which keeps literal lexical forms.
The reifier's other arcs are ordinary triples in the rdflib graph; the two
halves share the reifier by blank-node id or IRI.
:func:to_ox and :func:from_ox convert terms between rdflib and pyoxigraph.
Attributes¶
OxObject = ox.NamedNode | ox.BlankNode | ox.Literal | ox.Triple
module-attribute
¶
OxSubject = ox.NamedNode | ox.BlankNode
module-attribute
¶
Triple = tuple[Node, Node, Node]
module-attribute
¶
__all__ = ['ProvenanceFormatError', 'Reifications', 'from_ox', 'ox_triple', 'to_ox', 'triple_from_ox']
module-attribute
¶
Classes¶
ProvenanceFormatError
¶
Reifications
¶
The rdf:reifies statements of one graph: reifier and reified triple.
Source code in ontocast/onto/reification.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 | |
Methods:¶
__init__()
¶
__iter__()
¶
__len__()
¶
add(reifier, triple)
¶
Record that reifier reifies triple.
Raises:
| Type | Description |
|---|---|
TypeError
|
|
Source code in ontocast/onto/reification.py
add_ox(reifier, term)
¶
clear()
¶
copy()
¶
drop_mentioning(nodes)
¶
Remove the reifications whose triple mentions any of nodes.
Returns:
| Type | Description |
|---|---|
set[Node]
|
The reifiers removed, so the caller can drop their other arcs. |
Source code in ontocast/onto/reification.py
quads()
¶
reifiers()
¶
reifiers_of(triple)
¶
The reifiers of triple.
remove_reifiers(reifiers)
¶
Remove the statements of reifiers; returns how many.
Source code in ontocast/onto/reification.py
rename(rename_term)
¶
Apply rename_term to every term, as the graph's own rewrite does.
Returns:
| Type | Description |
|---|---|
int
|
The number of statements changed. |
Source code in ontocast/onto/reification.py
retarget(replacements)
¶
Repoint reifications from a replaced triple onto its replacement.
The reifier is kept, so its other arcs move with it.
Returns:
| Type | Description |
|---|---|
int
|
The number of statements repointed. |
Source code in ontocast/onto/reification.py
Functions:¶
from_ox(term)
¶
The rdflib term for a pyoxigraph term.
An xsd:string literal becomes a plain literal, as rdflib's own parsers
produce it.
Raises:
| Type | Description |
|---|---|
TypeError
|
|
Source code in ontocast/onto/reification.py
ox_triple(triple)
¶
The triple term for an rdflib triple, or None when one position
cannot hold its term (a literal subject, say).
Source code in ontocast/onto/reification.py
to_ox(term)
¶
The pyoxigraph term for an rdflib term, lexical form unchanged.
Raises:
| Type | Description |
|---|---|
TypeError
|
|