Skip to content

Instantly share code, notes, and snippets.

@aria42
Created September 19, 2010 19:33
Show Gist options
  • Save aria42/587049 to your computer and use it in GitHub Desktop.
Save aria42/587049 to your computer and use it in GitHub Desktop.
(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