What is this?
This package is a Dart port of markov-strings, and is for using a very simple string-based Markov chain in Dart.
Basic usage
// Create the chain.
final chain = MarkovChain(
MarkovChainOptions(
// You can customize stuff in here.
//
// Read the API docs to see what you can customize!
),
);
// Add some data.
chain.addData([
"a sentence 1",
"some words 2",
]);
// Generate!
final results = chain.generate(options: MarkovGenerationOptions(
// You can also customize stuff in here :)
));
print(results.string);
print("Tries: ${results.tries}");
// There's also more properties!
Importing and exporting
Markov chains can be saved and loaded from a MarkovData object.
final data = chain.export();
saveSomeData(data.toJson()); // The data support toJson and fromJson from json_serializable!
// Create a new chain from our data!
// All our data has been restored.
final chain = MarkovChain.import(data);
Libraries
- markov_strings
- Library for a very simple String-based Markov chain.