Skip to content

scambier/markov-strings-rust

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

markov_strings

A simplistic, configurable, Markov chain text generator. Give it an array of strings, and it will output a randomly generated string.

This is a port of the npm library markov-strings, from the same author.

Usage

use markov_strings::*;

// Instantiate the generator
let mut markov = Markov::new();

// Optional: specify a state size
markov.set_state_size(3); // Default: 2

// Feed it data
let data: Vec<InputData> = vec![/* a lot of data */];
markov.add_to_corpus(data);

// Define a results filter
markov
    .set_filter(|r| {
        // A minimal relative score and number of references
        // The thresholds are relative to your input
        r.score > 5 && r.refs.len() > 2
            // We want to generate random tweets
            && r.text.len() <= 280
            // No mentions
            && !r.text.contains("@")
            // No urls
            && !r.text.contains("http")
    })
    .set_max_tries(100);

let result: MarkovResult = markov.generate().unwrap();

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages