aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpukkamustard <pukkamustard@posteo.net>2021-06-28 09:59:18 +0200
committerpukkamustard <pukkamustard@posteo.net>2021-06-28 09:59:18 +0200
commite1d5560be2af20245caa876c856c1c7cf56fbd13 (patch)
tree5975ce3a9d4636679cc2f8d56a5a5441f1027ace
parent2851dfb698cc463640750faad765d2f9446dcf54 (diff)
Rdf_fragment_graph: Expose the `expand` functions.
-rw-r--r--lib/fragment_graph/rdf_fragment_graph.ml26
-rw-r--r--lib/fragment_graph/rdf_fragment_graph.mli10
2 files changed, 28 insertions, 8 deletions
diff --git a/lib/fragment_graph/rdf_fragment_graph.ml b/lib/fragment_graph/rdf_fragment_graph.ml
index 89ef2a7..967c91c 100644
--- a/lib/fragment_graph/rdf_fragment_graph.ml
+++ b/lib/fragment_graph/rdf_fragment_graph.ml
@@ -33,6 +33,11 @@ module type S = sig
val make_fragment_reference : string -> t
(** [make_fragment_reference fragment] creates a reference to [fragment] *)
+ val expand : base_subject:Rdf.Iri.t -> t -> Rdf.Triple.Predicate.t
+ (** [expand ~base_subject predicate] returns a predicate that can be used to
+ construct a triple from [predicate]. Fragment references are expanded to
+ full IRIs using the [base_subject].*)
+
val pp : t Fmt.t
[@@ocaml.toplevel_printer]
@@ -54,6 +59,11 @@ module type S = sig
val make_fragment_reference : string -> t
(** [make_fragment_reference fragment] creates a reference to [fragment] *)
+ val expand : base_subject:Rdf.Iri.t -> t -> Rdf.Triple.Object.t
+ (** [expand ~base_subject predicate] returns an object that can be used to
+ construct a triple from [object]. Fragment references are expanded to
+ full IRIs using the [base_subject].*)
+
val pp : t Fmt.t
[@@ocaml.toplevel_printer]
end
@@ -155,9 +165,9 @@ module Make(H: HASH) = struct
| FragmentReference _, _ -> -1
| Iri _, _ -> 1
- let expand base_iri = function
+ let expand ~base_subject = function
| FragmentReference fragment ->
- Rdf.Iri.with_fragment base_iri (Some fragment)
+ Rdf.Iri.with_fragment base_subject(Some fragment)
|> Rdf.Triple.Predicate.of_iri
| Iri iri ->
iri
@@ -201,9 +211,9 @@ module Make(H: HASH) = struct
| Literal _, _ -> -1
| Iri _, _ -> 1
- let expand base_iri = function
+ let expand ~base_subject = function
| FragmentReference fragment ->
- Rdf.Iri.with_fragment base_iri (Some fragment)
+ Rdf.Iri.with_fragment base_subject (Some fragment)
|> Rdf.Triple.Object.of_iri
| Iri iri ->
iri
@@ -513,8 +523,8 @@ module Make(H: HASH) = struct
(fun (p, o) ->
Rdf.Triple.make
subject
- (Predicate.expand base_subject p)
- (Object.expand base_subject o)))
+ (Predicate.expand ~base_subject p)
+ (Object.expand ~base_subject o)))
(fragment_graph
|> fragment_statements
|> Seq.map
@@ -524,8 +534,8 @@ module Make(H: HASH) = struct
in
Rdf.Triple.make
subject
- (Predicate.expand base_subject p)
- (Object.expand base_subject o)))
+ (Predicate.expand ~base_subject p)
+ (Object.expand ~base_subject o)))
let pp_statement ppf (p,o) =
diff --git a/lib/fragment_graph/rdf_fragment_graph.mli b/lib/fragment_graph/rdf_fragment_graph.mli
index 7277a3a..3ce8197 100644
--- a/lib/fragment_graph/rdf_fragment_graph.mli
+++ b/lib/fragment_graph/rdf_fragment_graph.mli
@@ -52,6 +52,11 @@ module type S = sig
val make_fragment_reference : string -> t
(** [make_fragment_reference fragment] creates a reference to [fragment] *)
+ val expand : base_subject:Rdf.Iri.t -> t -> Rdf.Triple.Predicate.t
+ (** [expand ~base_subject predicate] returns a predicate that can be used to
+ construct a triple from [predicate]. Fragment references are expanded to
+ full IRIs using the [base_subject].*)
+
val pp : t Fmt.t
[@@ocaml.toplevel_printer]
end
@@ -72,6 +77,11 @@ module type S = sig
val make_fragment_reference : string -> t
(** [make_fragment_reference fragment] creates a reference to [fragment] *)
+ val expand : base_subject:Rdf.Iri.t -> t -> Rdf.Triple.Object.t
+ (** [expand ~base_subject predicate] returns an object that can be used to
+ construct a triple from [object]. Fragment references are expanded to
+ full IRIs using the [base_subject].*)
+
val pp : t Fmt.t
[@@ocaml.toplevel_printer]
end