Skip to content

Commit

Permalink
Fix parsing of objects
Browse files Browse the repository at this point in the history
  • Loading branch information
ckindermann committed Dec 3, 2024
1 parent 2b515f6 commit d11726a
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/ldtab/thick_rdf.clj
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@
(translate-predicate-map (dissoc x "meta") prefix-2-base model)))))
bnode))


(defn parse-json
[json]
(let [success (try
Expand All @@ -151,6 +150,15 @@
(cs/parse-string json)
json)))

(defn parse-json-object
[json]
(let [object (:object json)
datatype (:datatype json)]
(if (or (= datatype "_JSONMAP")
(= datatype "_JSONLIST"))
(parse-json object)
object)))

(defn is-wiring-blanknode
[input]
(and (string? input)
Expand All @@ -159,12 +167,11 @@
(defn blanknode-triple-map
[blanknode-triples]
(cs/generate-string
(into {}
(map (fn [{:keys [predicate object datatype]}]
[predicate [{"object" (parse-json object),
"datatype" datatype}]])
blanknode-triples))))

(into {}
(map (fn [{:keys [predicate object datatype]}]
[predicate [{"object" (parse-json object),
"datatype" datatype}]])
blanknode-triples))))

(defn merge-existential-blanknodes
"Merge thin triples belonging to the same existential blank nodes into a 'raw' LDTab triple."
Expand All @@ -190,7 +197,7 @@
(let [;{:keys [assertion retraction graph s p o datatype annotation]} thick-triple
model (set-prefix-map (ModelFactory/createDefaultModel) prefixes)
prefix-2-base (get-prefix-map prefixes)
tt {"object" (parse-json (:object thick-triple))
tt {"object" (parse-json-object thick-triple)
"datatype" (:datatype thick-triple)}
;subject (translate-iri (:subject thick-triple) prefix-2-base model)
;provisional handling of GCIs (with JSON objects in the position of subject column)
Expand Down

0 comments on commit d11726a

Please sign in to comment.