Skip to content

Instantly share code, notes, and snippets.

@darcwader
Created October 29, 2017 13:57
Show Gist options
  • Select an option

  • Save darcwader/2acc8601a58b1c082d583ac14f0b8134 to your computer and use it in GitHub Desktop.

Select an option

Save darcwader/2acc8601a58b1c082d583ac14f0b8134 to your computer and use it in GitHub Desktop.
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