Skip to main content

Crate word_generator

Crate word_generator 

Source
Expand description

Utilities for generating random words that souds similar to a choosen language.

Word_generator provides utilities for generating words that souds similar to a choosen language. It uses Markov Chains under the name of ProbabilityTable to analyze the likehood of each characters to appears after the nths previous characters where n is variable. n can be consider as the accuracy

This idea came from a Science Étonnante’s video (in french)

§Example

use std::{fs::File, io::BufReader};
use word_generator::{langs, *};

// let reader = BufReader::new(File::open("Your_lang.txt")?); // using your language
let reader = BufReader::new(langs::FR_TXT); // or a preexisting language

// This
let table = ProbabilityTable::from_reader(reader, 3)?;
println!("{:?}", table.generate_words(15)); // Generate 15 word


// Is the same as this
println!("{:?}", generate_words(reader, 3, 15)?);

§Licences

Here is the list of licences of the languages on this crate:

  • French: free of use

If you have more language to add please submit a PR at the GitHub of this project

Modules§

langs
This module contains a list of lists of word of every word of a language. See the Licences section of the main module for more information about the licence of each lists

Structs§

ProbabilityTable
This is a Markov Chains under the name of ProbabilityTable. It represents the likehood of each characters of the language to appears after the nths previous caracters where n is variable. n can be consider as the accuracy

Functions§

generate_words
Generate amount word with choosable accuracy by analyzing a language under the form of a type that implement BufRead