Database Reference
In-Depth Information
(html/select [:a])
first
:attrs
:href
(string/split #"=")
last)]
(symbol "currency" (str code "#" code)))))
(defn get-td-a
([td]
(->> td
:content
(mapcat :content)
string/join
read-string)))
(defn get-data
([row]
(let [[td-header td-to td-from]
(filter map? (:content row))]
{:currency (td->code td-to)
:exchange-to (get-td-a td-to)
:exchange-from (get-td-a td-from)})))
3.
This function takes the data extracted from the HTML page and generates a list of
RDF triples:
(defn data->statements
([time-stamp data]
(let [{:keys [currency exchange-to]} data]
(list [currency 'err/exchangeRate exchange-to]
[currency 'err/exchangeWith
'currency/USD#USD]
[currency 'err/exchangeRateDate
[time-stamp 'xsd/dateTime]]))))
4. This function ties all of the processes that we just deined together by pulling the data
out of the web page, converting it to triples, and adding them to the database:
(defn load-exchange-data
"This downloads the HTML page and pulls the data out
of it."
[kb html-url]
 
Search WWH ::




Custom Search