Created
October 29, 2017 13:57
-
-
Save darcwader/2acc8601a58b1c082d583ac14f0b8134 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
| func countVector(sentence:String) -> [Int:Int]? { | |
| var vec = [Int:Int]() | |
| for word in self.tokenize(sentence) { | |
| if let pos = self.vocabulary[word] { | |
| if let i = vec[pos] { | |
| vec[pos] = i+1 | |
| } else { | |
| vec[pos] = 1 | |
| } | |
| } | |
| } | |
| return vec | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment