Database Reference
In-Depth Information
;; Get the results, parse the XML,
;; and return the zipper.
io/input-stream
xml/parse
zip/xml-zip
;; Find the first child.
zip/down
zip/right
zip/down
;; Convert all children into a sequence.
result-seq)))
7.
Finally, we can pull everything together. Here's load-data :
(defn load-data
"This loads the data about a currency for the
given URI."
[sparql-uri subject col-map]
(->>
;; Initialize the triple store.
(kb-memstore)
init-kb
;; Get the results.
(query-sparql-results sparql-uri subject)
;; Generate a mapping.
(map result-to-kv)
(reduce accum-hash {})
;; Translate the keys in the map.
(rekey col-map)
;; And create a dataset.
to-dataset))
8. Now, let's use this data. We can deine a set of variables to make it easier to
reference the namespaces we'll use. We'll use these to create the mapping to
column names:
(def rdfs "http://www.w3.org/2000/01/rdf-schema#")
(def dbpedia "http:///dbpedia.org/resource/")
(def dbpedia-ont "http://dbpedia.org/ontology/")
(def dbpedia-prop "http://dbpedia.org/property/")
(def col-map {(str rdfs 'label) :name,
(str dbpedia-prop 'usingCountries) :country
(str dbpedia-prop 'peggedWith) :pegged-with
(str dbpedia-prop 'symbol) :symbol
(str dbpedia-prop 'usedBanknotes) :used-banknotes
(str dbpedia-prop 'usedCoins) :used-coins
(str dbpedia-prop 'inflationRate) :inflation})
 
Search WWH ::




Custom Search