markov chain generation is pretty decent
This commit is contained in:
parent
4be3c5f12c
commit
8ff959a6f7
20 changed files with 25066 additions and 62 deletions
6
examples/word_count/views/markov/chain-map.js
Normal file
6
examples/word_count/views/markov/chain-map.js
Normal file
|
@ -0,0 +1,6 @@
|
|||
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);
|
||||
}
|
||||
}
|
7
examples/word_count/views/markov/chain-reduce.js
Normal file
7
examples/word_count/views/markov/chain-reduce.js
Normal file
|
@ -0,0 +1,7 @@
|
|||
function(key,vs,c){
|
||||
if (c) {
|
||||
return sum(vs);
|
||||
} else {
|
||||
return vs.length;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue