Database Reference
In-Depth Information
(let [html (html/html-resource html-url)
div (html/select html [:div.moduleContent])
time-stamp (normalize-date
(find-time-stamp div))]
(add-statements
kb
(mapcat (partial data->statements time-stamp)
(map get-data (find-data div))))))
That's a mouthful, but now that we can get all of the data into a triple store, we just need to
pull everything back out and into Incanter.
Loading currency data and tying it all together
Bringing the two data sources together and exporting it to Incanter is fairly easy at this point:
(defn aggregate-data
"This controls the process and returns the aggregated data."
[kb data-file data-url q col-map]
(load-rdf-file kb (File. data-file))
(load-exchange-data kb (URL. data-url))
(to-dataset (map (partial rekey col-map) (query kb q))))
We'll need to do a lot of the set up we've done before. Here, we'll bind the triple store, the
query, and the column map to names so that we can refer to them easily:
(def t-store (init-kb (kb-memstore)))
(def q
'((?/c rdf/type money/Currency)
(?/c money/name ?/name)
(?/c money/shortName ?/shortName)
(?/c money/isoAlpha ?/iso)
(?/c money/minorName ?/minorName)
(?/c money/minorExponent ?/minorExponent)
(:optional
((?/c err/exchangeRate ?/exchangeRate)
(?/c err/exchangeWith ?/exchangeWith)
(?/c err/exchangeRateDate ?/exchangeRateDate)))))
(def col-map {'?/name :fullname
'?/iso :iso
'?/shortName :name
'?/minorName :minor-name
 
Search WWH ::




Custom Search