markov_strings 0.0.1
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.
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);
}