couchrest_model/examples/word_count/views/markov/chain-map.js
2008-06-01 15:07:56 -07:00

6 lines
227 B
JavaScript

function(doc){
var words = doc.text.split(/\W/).filter(function(w) {return w.length > 0}).map(function(w){return w.toLowerCase()});
for (var i = 0, l = words.length; i < l; i++) {
emit(words.slice(i,4),doc.title);
}
}