Skip to content

Instantly share code, notes, and snippets.

@aria42
Created March 28, 2012 03:39
Show Gist options
  • Select an option

  • Save aria42/2223374 to your computer and use it in GitHub Desktop.

Select an option

Save aria42/2223374 to your computer and use it in GitHub Desktop.
;; bigrams key is a word and value
;; is a map of word counts
;; merge operation is merging map values with +
(def bigrams
(bucket/new
{:type :mem
:merge (partial merge-with +)}))
;; For each word, count following words
(doseq [[before after]
(partition-all 2 words)]
(bucket/merge bigrams
before {after 1}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment