9 Commits

Author SHA1 Message Date
b1461e24db Fix bug in Markov.Chain where reply_chance would get reset, add regression tests for this
* Markov.Chain.add_weight/4 would return a fresh new markov chain,
  instead of using all of the previous values of the chain that was
  being modified. This would result in resetting the reply_chance value
  to the default of 0.01.
* Add tests to make sure this doesn't happen to add_weights in the
  future.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-07-21 14:58:10 -07:00
9dc1033cd2 Add merge/1 and merge/2 to Markov.Chain
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>
2020-07-17 20:07:02 -07:00
e88bd58229 Update markov chains to be backed by maps instead of lists
This should hopefully speed up lookups and stuff like that.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-07-17 17:33:52 -07:00
4c93b42fdc Finish markov chain generation impl
* 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>
2020-07-15 16:25:25 -07:00
9c69ca7b72 Markov chains appear to be training correctly
* 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>
2020-07-08 17:25:26 -07:00
1a73a62a2c Add train/2 and add_weight/4 implementations to Markov Chain
* 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>
2020-07-08 12:59:34 -07:00
6d503089e4 Add binary search to Util
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>
2020-07-08 11:29:13 -07:00
67ba7a5847 WIP: Wordbot
Wordbot is a little more complex of a bot module and I've been working
on it here.

Other than wordbot module, a few minor tweaks have been added all around
that don't really affect anything.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-07-01 12:04:51 -07:00
0b01f3524e Add tests for Omnibot.Contrib.Linkbot
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-06-14 18:10:34 -04:00