markov-strings
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -8,3 +8,3 @@ 'use strict'; | ||
this.data = data; | ||
this.corpus = {}; | ||
this.corpus = undefined; | ||
this.startWords = []; | ||
@@ -42,2 +42,3 @@ this.endWords = []; | ||
this.corpus = {}; | ||
this.data.forEach(line => { | ||
@@ -91,2 +92,5 @@ const words = line.split(' '); | ||
generateSentenceSync(options, check) { | ||
if (!this.corpus) { | ||
throw new Error('Corpus is not built.') | ||
} | ||
options = options ? options : {}; | ||
@@ -93,0 +97,0 @@ _.assignIn(this.options, options); |
{ | ||
"name": "markov-strings", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "A Markov string generator", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -5,15 +5,40 @@ [![Build Status](https://travis-ci.org/scambier/markov-strings.svg?branch=master)](https://travis-ci.org/scambier/markov-strings) | ||
#Markov-strings | ||
<!-- TOC depthFrom:1 depthTo:6 withLinks:1 updateOnSave:1 orderedList:0 --> | ||
A simplistic Markov chain text generator. | ||
- [Markov-strings](#markov-strings) | ||
- [Prerequisites](#prerequisites) | ||
- [Installing](#installing) | ||
- [Usage](#usage) | ||
- [API](#api) | ||
- [new Markov(data, [options])](#new-markovdata-options) | ||
- [data](#data) | ||
- [options](#options) | ||
- [stateSize](#statesize) | ||
- [maxLength](#maxlength) | ||
- [minWords](#minwords) | ||
- [maxWords](#maxwords) | ||
- [minScore](#minscore) | ||
- [maxTries](#maxtries) | ||
- [markov.buildCorpus()](#markovbuildcorpus) | ||
- [markov.generateSentence([options])](#markovgeneratesentenceoptions) | ||
- [options](#options) | ||
- [Running the tests](#running-the-tests) | ||
<!-- /TOC --> | ||
# Markov-strings | ||
A simplistic Markov chain text generator. | ||
Give it an array of strings, and it will output a randomly generated string. | ||
##Prerequisites | ||
This module was created for the Twitter bot [@BelgicaNews](https://twitter.com/BelgicaNews). | ||
## Prerequisites | ||
This module makes use of ES6 features. | ||
##Installing | ||
## Installing | ||
`npm install --save markov-strings` | ||
##Usage | ||
## Usage | ||
@@ -57,3 +82,3 @@ ```javascript | ||
/* | ||
Possible output: | ||
Possible output: | ||
{ | ||
@@ -70,3 +95,3 @@ string: 'lorem ipsum dolor sit amet (etc.) https://github.com/scambier/markov-strings', | ||
## API | ||
### Markov(data, [options]) | ||
### new Markov(data, [options]) | ||
Create a generator instance. | ||
@@ -83,3 +108,3 @@ #### data | ||
The `options` object will alter the quality, length, etc. of the generated sentences. | ||
The `options` object will alter the quality, length, etc. of the generated sentences. | ||
@@ -129,6 +154,7 @@ Options given to `generateSentence()` overwrite those given during instantiation. | ||
Sentence generation can (will) take multiple tries to create one that will fulfill all restrictions. | ||
If this value is exceeded, an error will be thrown. | ||
If this value is exceeded, an error will be thrown. | ||
#### markov.buildCorpus() | ||
Return a Promise that will resolve to nothing. | ||
Return a Promise that will resolve to nothing. | ||
Synced function: `markov.buildCorpusSynced()` | ||
@@ -139,3 +165,4 @@ This function **must** be called to build the corpus for Markov generation. | ||
#### markov.generateSentence([options]) | ||
Return a Promise that will resolve to an object `{string, score}` | ||
Return a Promise that will resolve to an object `{string, score}` | ||
Synced function: `markov.generateSetnenceSynced()` | ||
@@ -142,0 +169,0 @@ ##### options |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15442
246
170