markov chain generation is pretty decent
This commit is contained in:
parent
4be3c5f12c
commit
8ff959a6f7
20 changed files with 25066 additions and 62 deletions
3
examples/word_count/views/books/chunked-map.js
Normal file
3
examples/word_count/views/books/chunked-map.js
Normal file
|
@ -0,0 +1,3 @@
|
|||
function(doc) {
|
||||
doc.title && doc.chunk && emit([doc.title, doc.chunk],null);
|
||||
}
|
1
examples/word_count/views/books/united-map.js
Normal file
1
examples/word_count/views/books/united-map.js
Normal file
|
@ -0,0 +1 @@
|
|||
function(doc){if(doc.text && doc.text.match(/united/)) emit([doc.title, doc.chunk],null)}
|
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;
|
||||
}
|
||||
}
|
6
examples/word_count/views/word_count/count-map.js
Normal file
6
examples/word_count/views/word_count/count-map.js
Normal file
|
@ -0,0 +1,6 @@
|
|||
function(doc){
|
||||
var words = doc.text.split(/\W/).map(function(w){return w.toLowerCase()});
|
||||
words.forEach(function(word){
|
||||
if (word.length > 0) emit([word,doc.title],1);
|
||||
});
|
||||
}
|
3
examples/word_count/views/word_count/count-reduce.js
Normal file
3
examples/word_count/views/word_count/count-reduce.js
Normal file
|
@ -0,0 +1,3 @@
|
|||
function(key,combine){
|
||||
return sum(combine);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue