Created
September 19, 2010 19:59
-
-
Save aria42/587068 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
| (defn obs-transitions | |
| "if we set word to tag, we update the transition tag counts | |
| from all context usages of word by weight amount" | |
| [trans-distrs type-assigns word-info tag weight] | |
| (reduce | |
| (fn [res [[before after] count]] | |
| (let [type-assigns (assoc type-assigns (:word word-info) tag) | |
| before-tag (type-assigns before) | |
| after-tag (type-assigns after)] | |
| (-> res | |
| ;; Observe P(tag | tag-assign(before)) | |
| (update-in [before-tag] observe tag (* count weight)) | |
| ;; Observe P(tag-assign(after) | tag) | |
| (update-in [tag] observe after-tag (* count weight))))) | |
| trans-distrs | |
| (-> word-info :contexts :counts))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment