add readme
parent
a0666b94a0
commit
d3734e3c5d
|
@ -0,0 +1,44 @@
|
||||||
|
# incantata
|
||||||
|
|
||||||
|
incantata is a rust library that generates random words according to a provided structure
|
||||||
|
|
||||||
|
```rust
|
||||||
|
use incantata::*;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
// structure of the language
|
||||||
|
let s = Structure {
|
||||||
|
// how many characters the onset is
|
||||||
|
onset: 1,
|
||||||
|
// allowed characters for the onset
|
||||||
|
onset_dict: CONSONANTS.chars().collect(),
|
||||||
|
|
||||||
|
// how many characters the nucleus is
|
||||||
|
nucleus: 1,
|
||||||
|
// allowed characters for the nucleus
|
||||||
|
nucleus_dict: VOCALS
|
||||||
|
.chars()
|
||||||
|
.cycle()
|
||||||
|
.take(VOCALS.len() * 5)
|
||||||
|
// .chain(VOCALS_ACCENTS.chars())
|
||||||
|
.collect(),
|
||||||
|
|
||||||
|
// how many characters the coda is
|
||||||
|
coda: 0,
|
||||||
|
// allowed characters for the coda
|
||||||
|
coda_dict: CONSONANTS.chars().collect(),
|
||||||
|
|
||||||
|
// minimum length of a word
|
||||||
|
min_len: 4,
|
||||||
|
// the words will be generated to be around this length
|
||||||
|
// due to the way incantata works (by combining valid syllables),
|
||||||
|
// we can't actually make a word of a given length
|
||||||
|
suggested_len: 15,
|
||||||
|
};
|
||||||
|
|
||||||
|
// generate 10 words
|
||||||
|
for _ in 0..10 {
|
||||||
|
println!("{}", incantata(&s));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
16
src/bin.rs
16
src/bin.rs
|
@ -1,23 +1,37 @@
|
||||||
use incantata::*;
|
use incantata::*;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
// structure of the language
|
||||||
let s = Structure {
|
let s = Structure {
|
||||||
|
// how many characters the onset is
|
||||||
onset: 1,
|
onset: 1,
|
||||||
|
// allowed characters for the onset
|
||||||
onset_dict: CONSONANTS.chars().collect(),
|
onset_dict: CONSONANTS.chars().collect(),
|
||||||
|
|
||||||
|
// how many characters the nucleus is
|
||||||
nucleus: 1,
|
nucleus: 1,
|
||||||
|
// allowed characters for the nucleus
|
||||||
nucleus_dict: VOCALS
|
nucleus_dict: VOCALS
|
||||||
.chars()
|
.chars()
|
||||||
.cycle()
|
.cycle()
|
||||||
.take(VOCALS.len() * 5)
|
.take(VOCALS.len() * 5)
|
||||||
.chain(VOCALS_ACCENTS.chars())
|
// .chain(VOCALS_ACCENTS.chars())
|
||||||
.collect(),
|
.collect(),
|
||||||
|
|
||||||
|
// how many characters the coda is
|
||||||
coda: 0,
|
coda: 0,
|
||||||
|
// allowed characters for the coda
|
||||||
coda_dict: CONSONANTS.chars().collect(),
|
coda_dict: CONSONANTS.chars().collect(),
|
||||||
|
|
||||||
|
// minimum length of a word
|
||||||
min_len: 4,
|
min_len: 4,
|
||||||
|
// the words will be generated to be around this length
|
||||||
|
// due to the way incantata works (by combining valid syllables),
|
||||||
|
// we can't actually make a word of a given length
|
||||||
suggested_len: 15,
|
suggested_len: 15,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// generate 10 words
|
||||||
for _ in 0..10 {
|
for _ in 0..10 {
|
||||||
println!("{}", incantata(&s));
|
println!("{}", incantata(&s));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue