Created
March 28, 2012 03:39
-
-
Save aria42/2223374 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;; 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