Skip to content

Instantly share code, notes, and snippets.

View atharrison's full-sized avatar

Andrew Harrison atharrison

  • Austin, TX
  • 07:56 (UTC -05:00)
View GitHub Profile
@wetmore
wetmore / cosine-sim.js
Created July 30, 2012 03:52
Cosine similarity calculator
var _ = require('underscore');
var freqVector = function(word, letters) {
var freq = _.groupBy(word.split(''), function(l) {return l;});
return _.map(letters, function(l) {
return freq[l] ? freq[l].length : 0;
});
};
var dot = function(v1, v2) {