algebraixlib.util.rdf module¶
RDF-specific data manipulation facilities.
The code is RDF/SPARQL-inspired but does not officially implement any RDF standards.
Glossary¶
- triple
- A function with three members, with the left components
's'
,'p'
,'o'
. A generic triple is an element of \(P(A \times M)\); an RDF triple is an element of \(P(A \times A)\). (See also set A and set M.) - graph
- A clan where every relation it contains is a triple. A generic graph is an element of \(P^2(A \times M)\); an RDF graph is an element of \(P^2(A \times A)\). (See also set A and set M.)
API¶
-
algebraixlib.util.rdf.
is_file_url
(path_or_url: str) → bool[source]¶ Return
True
ifpath_or_url
is a file URL,False
if not.As valid file URL we consider any URL that starts with
'file://'
).
-
algebraixlib.util.rdf.
get_file_url
(path: str) → str[source]¶ Return the file URL that corresponds to the file path
path
.If
path
is relative, it is converted into an absolute path before being converted into a file URL.
-
algebraixlib.util.rdf.
is_triple
(obj: algebraixlib.mathobjects.mathobject.MathObject) → bool[source]¶ Return
True
ifobj
is a validtriple
,False
if not.
-
algebraixlib.util.rdf.
is_absolute_triple
(obj: algebraixlib.mathobjects.mathobject.MathObject) → bool[source]¶
-
algebraixlib.util.rdf.
make_triple
()[source]¶ Return an RDF
triple
, created fromsubject
,predicate
andobject_
.Each of the arguments must be an instance of
MathObject
or a Python type that automatically converts to anAtom
in theCouplet
constructor.
-
algebraixlib.util.rdf.
is_graph
(obj: algebraixlib.mathobjects.mathobject.MathObject) → bool[source]¶ Return
True
ifobj
is agraph
,False
if not.
-
algebraixlib.util.rdf.
is_absolute_graph
(obj: algebraixlib.mathobjects.mathobject.MathObject) → bool[source]¶
-
algebraixlib.util.rdf.
triple_match
()[source]¶ Evaluate SPARQL-like triple pattern matches.
Treat string values for subject, predicate, object that begin with
'?'
or'$'
similarly to SPARQL variables; they define the projection (output) lefts. Other values are used for matching.Parameters: - rdf_graph – The
graph
on which to operate. - subject – Handle the subjects in
rdf_graph
: a variable name (create output), a value that’s not a variable name (match) orNone
(ignore). - predicate – Handle the predicates in
rdf_graph
: a variable name (create output), a value that’s not a variable name (match) orNone
(ignore). - object – Handle the objects in
rdf_graph
: a variable name (create output), a value that’s not a variable name (match) orNone
(ignore).
Returns: A clan with the matches.
- rdf_graph – The
-
algebraixlib.util.rdf.
join
(rdf_solution1, rdf_solution2, *rdf_solutions)[source]¶ Return the cross-functional union of all arguments.
This is a thin wrapper around
clans.cross_functional_union()
.