2 releases
0.1.1 | Aug 30, 2021 |
---|---|
0.1.0 | Aug 1, 2021 |
#2663 in Algorithms
75KB
124 lines
Tiny word generator
This is a little project I made to learn rust.
The goal was to make a program that take as input a list of word from a language and generate random word based on the language.
The list of word is free of rights and in french.
This idea come from a video of Science étonnante (in french)
lib.rs
:
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
Dependencies
~310KB