I have a document hash which is a reference like this:
(def *document-hash* (ref (hash-map)))
It looks like this
{"documentid" {:term-detail {"term1" count1 ,"term2" count2}, "doclen" 33}}}
How do I add to this hash table?Right now I have
(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 term-details for the documents
- Every time a new term comes, I want to get the term-details and update the terms and its count
- initially the hash is empty
But this throws the null pointer exception because ther term-detail hash is not created when I try to add the term-number.