// read in three text files
(
b = (); // maybe set path by hand if needed
b.folder = Document.current.path.dirname ++ Platform.pathSeparator;
b.textnames = [ \erlkoenig, \erlEng, \billOfRights];
b.textnames.do { |textname|
var lines;
var path = b.folder ++ textname ++ ".txt";
var file = File(path, "r");
if (file.isOpen) {
lines = file.readAllString.split($@);
b[textname] = lines;
file.close;
} { };
};
// make a number of new text generations,
// and compare them for occurrence within originals.
b.genTextSimple = { arg dict, numGenerations, corpus, starterLength, minDepth;
var corpusSnake = ContextSnake(corpus, minDepth: minDepth, starterLength: starterLength);
var count = 0, result;
while({ count < numGenerations },
{
result = corpusSnake.randStarter.asStream.all.join;
if (corpusSnake.isNew(result),
{ count = count+1;
result.postcs;
})
});
};
)
// check they are there
b.erlkoenig.printAll;"";
b.erlEng.printAll;"";
b.billOfRights.printAll;"";
7.do { b.genTextSimple(1, b.billOfRights, 4, 4) };
7.do { b.genTextSimple(1, b.erlEng, 4, 4) };
7.do { b.genTextSimple(1, b.erlkoenig, 4, 4) };