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.

example/example.dart

import 'package:markov_strings/markov_strings.dart';

void main(List<String> arguments) {
  final chain = MarkovChain(.new(
    stateSize: .tryParse(arguments.firstOrNull ?? "") ?? 2,
  ));

  chain.addData([
    'the quick brown fox jumps over the lazy dog',
    'the quick red hen runs across the farm',
    'the lazy dog sleeps under the old oak tree',
    'a small brown fox hides behind the old barn',
    'the old farmer feeds the red hen every morning',
    'the red hen runs away from the quick brown fox',
    'every morning the lazy dog barks at the old farmer',
    'the farm is quiet when the lazy dog sleeps',
    'a quick brown rabbit jumps over the old fence',
    'the old oak tree stands behind the quiet barn',
  ]);

  final result = chain.generate(options: .new(
    random: .secure(),
  ));

  print("Chain: $chain");
  print("Result: $result");

  print("");
  print(result.string);
}
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