Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

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