Evelios / elm-markov / Markov.String

Train a markov model for string generation. This module provides some wrapper functionality around the markov module so that you can do word generation. Sentence generation using markov models is fairly straight forward by using lists of Strings as training data. Just like how the core String module makes some character operations easier this section helps to wrap List Char operations into a more simpler String interface. This module contains only the operations that benefit from simplification not covered by the core library. This sections also serves as a good template on how to extend the markov package for use in your own data.

Types


type alias MarkovString =
Markov Basics.Int Char

A type alias for a markov graph which is used on determining probabilities of character transitions in words.

Builders

empty : MarkovString

Create an empty markov string object.

Modifiers

train : String -> MarkovString -> MarkovString

Train the markov model on a single string. This trains the model to store the transition probabilities of all the letters within the string as well as the probabilities to start with the first character and end with the last character.

trainList : List String -> MarkovString -> MarkovString

Train the model on a sample of data or an entire corpus.

Json

encode : MarkovString -> Json.Encode.Value

Encode the markov string model into a json object.

decode : Json.Decode.Decoder MarkovString

Decode a json object into a markov string model.