Created
September 19, 2010 19:33
-
-
Save aria42/587049 to your computer and use it in GitHub Desktop.
This file contains 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
(defn assoc-if-absent [m k f] | |
(if (m k) m (assoc m k (f k)))) | |
(defn tally-sent [vocab sent] | |
(reduce | |
(fn [res [before word after]] | |
(-> res | |
(assoc-if-absent word new-word-info) | |
(update-in [word] tally-usage before after))) | |
vocab | |
(partition 3 1 sent))) | |
(defn build-vocab [sents] | |
(vals (reduce tally-sent {} sents))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment