Every time a user sends a message, there is now a chance that markov
will reply with a random message based on what they said. !markov chance
allows lookups and setting of the chance that a user may receive a
message.
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
merge/1 takes a nonempty list of markov chains to merge
merge/2 takes two markov chains of the same order and sums their weights
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
* Markov chains will train and generate chains correctly now
* Implement Markov.save_chains/0
* Add a couple more utils that help accomplish the above
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
* Markov chains record words correctly from a single line to the end of
their line with a couple of exceptions.
* Start working on using ETS for storing markov chains, and saving it as
a DETS periodically
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
* train/2 takes a chain and a list of words to train them on
* add_weight/4 takes a chain, a list of words (the key), the word it
points to, and an optional increment which will increment the value of
a weight, or insert the weight.
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
For some reason there doesn't appear to be a binary search function in
Elixir's standard library, so this implements that.
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>