defmodule Nola.IRC.TxtPlugin.MarkovNative do @behaviour Nola.IRC.TxtPlugin.Markov def start_link() do ExChain.MarkovModel.start_link() end def reload(data, markov) do data = data |> Enum.map(fn({_, data}) -> for {line, _idx} <- data, do: line end) |> List.flatten ExChain.MarkovModel.populate_model(markov, data) :ok end def sentence(markov) do case ExChain.SentenceGenerator.create_filtered_sentence(markov) do {:ok, line, _, _} -> {:ok, line} error -> error end end def complete_sentence(sentence, markov) do case ExChain.SentenceGenerator.complete_sentence(markov, sentence) do {line, _} -> {:ok, line} error -> error end end end