aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpukkamustard <pukkamustard@posteo.net>2022-01-23 21:35:30 +0100
committerpukkamustard <pukkamustard@posteo.net>2022-01-23 21:35:30 +0100
commit3ab4aaa79f13ffe18e39497c4401018c3bd639a8 (patch)
tree937e42db1bc6e6f1d9964872fcb4b54f1dd41810
parent451783c930a819742446867d32a2b72737171e16 (diff)
Rdf_fragment_graph: Add add_opt_fragment_statement.HEADmain
-rw-r--r--lib/fragment_graph/rdf_fragment_graph.ml12
-rw-r--r--lib/fragment_graph/rdf_fragment_graph.mli6
2 files changed, 18 insertions, 0 deletions
diff --git a/lib/fragment_graph/rdf_fragment_graph.ml b/lib/fragment_graph/rdf_fragment_graph.ml
index 3c01371..e055c31 100644
--- a/lib/fragment_graph/rdf_fragment_graph.ml
+++ b/lib/fragment_graph/rdf_fragment_graph.ml
@@ -93,6 +93,12 @@ module type S = sig
val add_fragment_statement : string -> Predicate.t -> Object.t -> t -> t
(** [add_fragment_statement] adds a fragment statement to the fragment graph *)
+ val add_opt_fragment_statement :
+ string -> Predicate.t -> Object.t option -> t -> t
+ (** [add_opt_statement predicate object' fragment_graph] adds a
+ fragment statement to the fragment graph if [object'] holds an
+ object. Otherwise returns [fragment_graph] unmodified. *)
+
val of_triples : Rdf.Triple.t Seq.t -> (Rdf.Iri.t * t) Seq.t
(** [of_triples triples] returns a sequence of fragment graphs for each base
subject appearing in [triples]. *)
@@ -270,6 +276,12 @@ module Make (H : HASH) = struct
|> fragment_statement_union fragment_graph.fragment_statements;
}
+ let add_opt_fragment_statement fragment predicate object' fragment_graph =
+ match object' with
+ | Some object' ->
+ add_fragment_statement fragment predicate object' fragment_graph
+ | None -> fragment_graph
+
(* Constructor from triples *)
module IriMap = Map.Make (Rdf.Iri)
diff --git a/lib/fragment_graph/rdf_fragment_graph.mli b/lib/fragment_graph/rdf_fragment_graph.mli
index 7f1149e..430414f 100644
--- a/lib/fragment_graph/rdf_fragment_graph.mli
+++ b/lib/fragment_graph/rdf_fragment_graph.mli
@@ -102,6 +102,12 @@ module type S = sig
(** [add_fragment_statement fragment_identifier predicate object']
adds a fragment statement to the fragment graph. *)
+ val add_opt_fragment_statement :
+ string -> Predicate.t -> Object.t option -> t -> t
+ (** [add_opt_statement predicate object' fragment_graph] adds a
+ fragment statement to the fragment graph if [object'] holds an
+ object. Otherwise returns [fragment_graph] unmodified. *)
+
val of_triples : Rdf.Triple.t Seq.t -> (Rdf.Iri.t * t) Seq.t
(** [of_triples triples] returns a sequence of fragment graphs for each base
subject appearing in [triples].