Commit Graph

6 Commits

Author SHA1 Message Date
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