markov chain generation is pretty decent

This commit is contained in:
Chris Anderson 2008-06-01 15:07:56 -07:00
parent 4be3c5f12c
commit 8ff959a6f7
20 changed files with 25066 additions and 62 deletions

View file

@ -0,0 +1,3 @@
function(doc) {
doc.title && doc.chunk && emit([doc.title, doc.chunk],null);
}

View file

@ -0,0 +1 @@
function(doc){if(doc.text && doc.text.match(/united/)) emit([doc.title, doc.chunk],null)}

View 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);
}
}

View file

@ -0,0 +1,7 @@
function(key,vs,c){
if (c) {
return sum(vs);
} else {
return vs.length;
}
}

View 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);
});
}

View file

@ -0,0 +1,3 @@
function(key,combine){
return sum(combine);
}