Skip to main content

markov_strings 0.0.1 copy "markov_strings: ^0.0.1" to clipboard
markov_strings: ^0.0.1 copied to clipboard

A port of the TypeScript package markov-strings for using simple string-based Markov chains in dart.

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);
0
likes
160
points
485
downloads

Documentation

API reference

Publisher

verified publishercalebh101.net

Weekly Downloads

A port of the TypeScript package markov-strings for using simple string-based Markov chains in dart.

Repository (GitHub)
View/report issues

License

GPL-3.0 (license)

Dependencies

collection, json_annotation

More

Packages that depend on markov_strings