markov 2.0.1

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 50

markov

Build Status

A simple Markov chain implementation. Generates words and punctuation. Tuned for tweets.

Usage

Look at example/stdin_example.dart for a simple way of generating new text based on text provided through POSIX standard input.

Changelog

2.0.0

  • Upgrade to Dart 2

1.0.0

  • Go from Converter to a StreamConsumer

0.0.1

  • Initial version, created by Stagehand
  • Very limited testing

example/example.dart

// Copyright (c) 2016, <your name>. All rights reserved. Use of this source code
// is governed by a BSD-style license that can be found in the LICENSE file.

library markov.example;

import 'dart:async';
import 'dart:convert';
import 'dart:io';

import 'package:markov/markov.dart';

Future<void> main() async {
  print('Provide source text by stdin. For best result, provide a large number '
      'of tweets, one per line.\n\n'
      '  \$ dart example.dart < tweets.txt\n'
      '  Here\'s your generated tweet.');

  // Take POSIX standard input stream (or any other byte
  // stream) and use it as source text.
  final chain = await stdin
      .transform(const Utf8Decoder())
      .transform(const LineSplitter())
      .pipe(MarkovChainGenerator(2));

  // Take just one tweet worth of generated content (terminated by a newline).
  final List<Token> tokens =
      chain.generate().takeWhile((token) => token.string != '\n').toList();

  print(format(tokens));
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  markov: ^2.0.1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:markov/markov.dart';
  
Version Uploaded Documentation Archive
2.0.1 Aug 6, 2018 Go to the documentation of markov 2.0.1 Download markov 2.0.1 archive
2.0.0 Jul 23, 2018 Go to the documentation of markov 2.0.0 Download markov 2.0.0 archive
1.0.3 Nov 23, 2017 Go to the documentation of markov 1.0.3 Download markov 1.0.3 archive
1.0.2 Nov 23, 2017 Go to the documentation of markov 1.0.2 Download markov 1.0.2 archive
1.0.1 Mar 10, 2016 Go to the documentation of markov 1.0.1 Download markov 1.0.1 archive
1.0.0 Mar 9, 2016 Go to the documentation of markov 1.0.0 Download markov 1.0.0 archive
0.1.0 Mar 9, 2016 Go to the documentation of markov 0.1.0 Download markov 0.1.0 archive
0.0.2 Mar 8, 2016 Go to the documentation of markov 0.0.2 Download markov 0.0.2 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
50
Learn more about scoring.

We analyzed this package on Aug 10, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.11.8

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:markov/markov.dart.

Suggestions

Format lib/src/chain.dart.

Run dartfmt to format lib/src/chain.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev <3.0.0
quiver ^2.0.0 2.0.0+1
string_scanner ^1.0.3 1.0.3
Transitive dependencies
charcode 1.1.2
matcher 0.12.4
meta 1.1.6
path 1.6.2
source_span 1.4.1
stack_trace 1.9.3
Dev dependencies
test ^1.3.0