aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorarie <arie@alleycat.cc>2021-06-29 10:18:32 +0200
committerarie <arie@alleycat.cc>2021-06-29 10:18:32 +0200
commite6bbf3a31f2d7c9a6975af6631d50771c7b01fa8 (patch)
tree4a0720d8def0b7dd51503af1e8e2ab3d75777b92 /lib
parent49a0b6e0034fc411963bf3cc2bc1c6f046dcc389 (diff)
Add turtle tests. Almost done, some small strange behavior with literal.
Diffstat (limited to 'lib')
-rw-r--r--lib/core/graph.ml1
-rw-r--r--lib/turtle/rdf_turtle.ml20
2 files changed, 10 insertions, 11 deletions
diff --git a/lib/core/graph.ml b/lib/core/graph.ml
index 49c161f..f923a4e 100644
--- a/lib/core/graph.ml
+++ b/lib/core/graph.ml
@@ -4,7 +4,6 @@
But not in any other.This can be improved.
*)
-<<<<<<< HEAD
module TermMap = Map.Make(Term)
module TermSet = Set.Make(Term)
diff --git a/lib/turtle/rdf_turtle.ml b/lib/turtle/rdf_turtle.ml
index 9128abb..5041df5 100644
--- a/lib/turtle/rdf_turtle.ml
+++ b/lib/turtle/rdf_turtle.ml
@@ -8,7 +8,7 @@ open Rdf
let create_blank_node (state:Ast.state) =
let i = state.bnode_counter in
{state with bnode_counter = state.bnode_counter + 1},
- Blank_node.of_string @@ ("bnode" ^ string_of_int i)
+ Blank_node.of_string @@ ("genid" ^ string_of_int i)
(* TODO do we need to do something with the state here? Can prefixes depend on previous prefixes?
* In that case it would be necessary *)
@@ -81,7 +81,7 @@ let rec mk_collection : Blank_node.t -> (Ast.state * Graph.t) -> Ast.object' lis
(* Fmt.pr "Im in mk_collection [x] : hi!@."; *)
let sub_bnode = Triple.Subject.of_blank_node @@ bnode in
let (state, g) = insert_pred sub_bnode first_pred (state, g) obj in
- let g = Graph.add g (Triple.make sub_bnode rest_pred nil_obj) in
+ let g = Graph.add (Triple.make sub_bnode rest_pred nil_obj) g in
let (state, new_bnode) = create_blank_node state in
(state, g), new_bnode
| head :: tail ->
@@ -90,7 +90,7 @@ let rec mk_collection : Blank_node.t -> (Ast.state * Graph.t) -> Ast.object' lis
let (state, g) = insert_pred sub_bnode first_pred (state, g) head in
let (state, new_bnode) = create_blank_node state in
let obj_bnode = Triple.Object.of_blank_node @@ new_bnode in
- let g = Graph.add g (Triple.make sub_bnode rest_pred obj_bnode) in
+ let g = Graph.add (Triple.make sub_bnode rest_pred obj_bnode) g in
mk_collection new_bnode (state, g) tail
| _ -> raise @@ Invalid_argument "This list cannot be empty."
@@ -109,13 +109,13 @@ and mk_collection_obj : Triple.Subject.t -> Triple.Predicate.t -> Ast.state * Gr
fun sub pred (state, g) objs ->
match objs with
| [] ->
- let g = Graph.add g (Triple.make sub pred nil_obj) in
+ let g = Graph.add (Triple.make sub pred nil_obj) g in
(state, g)
| objs ->
let (state, bnode) = create_blank_node state in
let (state, g), _bnode = mk_collection bnode (state, g) objs in
let obj_bnode = Triple.Object.of_blank_node @@ bnode in
- let g = Graph.add g (Triple.make sub pred obj_bnode) in
+ let g = Graph.add (Triple.make sub pred obj_bnode) g in
(state, g)
(* We match on objects *)
@@ -130,7 +130,7 @@ and insert_pred : Triple.Subject.t -> Triple.Predicate.t -> Ast.state * Graph.t
| Obj_iri i ->
(* Fmt.pr "Im in insert_pred; hi!@."; *)
let rdf_obj = Triple.Object.of_iri (iri_of_resource state i) in
- let g = Graph.add g (Triple.make sub pred rdf_obj) in
+ let g = Graph.add (Triple.make sub pred rdf_obj) g in
(state, g)
| Obj_blank_node bnode ->
let rdf_obj =
@@ -138,7 +138,7 @@ and insert_pred : Triple.Subject.t -> Triple.Predicate.t -> Ast.state * Graph.t
|> Blank_node.of_string
|> Triple.Object.of_blank_node
in
- let g = Graph.add g (Triple.make sub pred rdf_obj) in
+ let g = Graph.add (Triple.make sub pred rdf_obj) g in
(state, g)
| Obj_literal { value; datatype; language } ->
(* Fmt.pr "Im in insert_pred literal; hi!@."; *)
@@ -150,14 +150,14 @@ and insert_pred : Triple.Subject.t -> Triple.Predicate.t -> Ast.state * Graph.t
rdf_iri_datatype
?language)
in
- let g = Graph.add g (Triple.make sub pred rdf_obj) in
+ let g = Graph.add (Triple.make sub pred rdf_obj) g in
(state, g)
| Obj_coll (Collection objs) -> mk_collection_obj sub pred (state, g) objs
| Obj_bnodps (BnodPs obj_predobjs) ->
let (state, bnode) = create_blank_node state in
let obj_bnode = Triple.Object.of_blank_node @@ bnode in
let sub_bnode = Triple.Subject.of_blank_node @@ bnode in
- let g = Graph.add g (Triple.make sub pred obj_bnode) in
+ let g = Graph.add (Triple.make sub pred obj_bnode) g in
let (state, g) = List.fold_left (insert_sub_predobj sub_bnode) (state, g) obj_predobjs in
(state, g)
@@ -241,7 +241,7 @@ let decode str =
let state : Ast.state = {
base_uri = base_iri;
namespaces = namespaces;
- bnode_counter = 0;
+ bnode_counter = 1;
} in
let g = Graph.empty in
str