You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The back-end logic for managing the Markov chain is available as a standalone
32
32
CoffeeScript module. It's flexible enough for you to use in your own project,
@@ -53,21 +53,23 @@ Setup
53
53
-----
54
54
After including the script, `Markov` objects can be constructed like this:
55
55
56
-
markov = new window.Markov ["sassafras", "mississippi"], 1
56
+
markov = new Markov ["sassafras", "mississippi"], 1
57
57
58
58
# Or, on CommonJS:
59
-
# markov = new Markov.Markov ["sassafras", "mississippi"], 1
59
+
# Markov = require "./markov"
60
+
# markov = new Markov ["sassafras", "mississippi"], 1
60
61
61
62
The first parameter to the constructor is an array of sequences. The sequences
62
63
are combined together to form the corpus. The generator takes care not to link
63
64
elements across sequence boundaries. In the example above, the last S in *sassafras*
64
-
is not associated with the M in *mississippi.* If you really *do* want that to happen,
65
-
here's how to do it:
65
+
is not associated with the M in *mississippi.* If you really *do* want those letters
66
+
to be associated, here's how to do it:
66
67
67
-
markov = new window.Markov["sassafrasmississippi"], 1
68
+
markov = new Markov["sassafrasmississippi"], 1
68
69
69
70
The second parameter to the constructor is *n,* the *Markov order* - basically, how
70
-
many previous elements the next element depends on. Low values make the Markov chain more random, while high values make it stick closer to the corpus.
71
+
many previous elements the next element depends on. Low values make the Markov
72
+
chain more random, while high values make it stick closer to the corpus.
71
73
72
74
If left unspecified, the array of sequences defaults to `[]` and the Markov order defaults to `2`.
73
75
@@ -81,17 +83,17 @@ Generation
81
83
Make the Markov chain do something useful with `.generate()`. Note that it returns
82
84
an array, so if you want a string you'll have to use `.join("")`.
83
85
84
-
markov = new window.Markov ["sassafras", "mississippi"]
0 commit comments