I have a hash document called a link:
(def *document-hash* (ref (hash-map)))
Looks like this
{"documentid" {:term-detail {"term1" count1 ,"term2" count2}, "doclen" 33}}}
How to add to this hash table? I have now
(defn add-doc-hash [docid term-number count]
(dosync (alter *document-hash*
(fn [a-hash]
(assoc a-hash docid {:term-detail
(assoc ((a-hash docid)) :term-detail) term-number count), :doclen 33))))))
- I want to update the detail terms for documents.
- Every time a new term arrives, I want to get the detail terms and update the terms and their number
- the hash is initially empty
But this eliminates the null pointer exception, because the term-detail hash is not created when I try to add a number term.
source
share