diff --git a/README.md b/README.md index bc36633..6f4a2ca 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,8 @@ ilo ni li musi taso. ona li ken pali e nimi sin, e kon pi nimi sin ni. kin la, ona li pali e toki ni: ona li kepeken nimi ni. +ona li lon https://nimisin.kittycat.homes + mi pali e ni tan ni: mi wile kama sona pi ilo Rust. ni li pali musi li pali pona tawa wile ni. sina lukin e ijo ike pi ilo ni la, o toki e ni tawa mi! sina ken toki tawa mi kepeken ilo Matrix lon @rawtess@matrix.kittycat.homes kepeken ilo Siko lon oωo 󱥢󱦐󱥾󱤊󱥦󱤀󱦑#5356 diff --git a/nimi b/nimi index f856c72..37e7656 100644 --- a/nimi +++ b/nimi @@ -1,3 +1,46 @@ +roused to ire; +arising from anger; +filled with or characterized by boredom; +someone who has a parent in common with another; +one related to another by common ties or interests; +a value that summarizes the general signifance of a set of unequal values; +being about midway between extremes; +not out of the ordinary; +to be average; +physical magnitude, extent, or bulk; +one of a series of graduated measures especially of manufactured articles conventionally identified by numbers or letters; +character, quality, or status of a person or thing with reference to importance, relative merit, or correspondence to needs; +actual state of affairs; +marked with spots; +being sullied; +characterized by the appearence of spots; +a physical or mental competition conducted according to rules with the participants in direct opposition to each other; +a division of a larger contest; +the manner of playing in a contest; +a particular aspect or phase of play in a game or sport; +the set of rules governing a game; +an activity engaged in for diversion or amusement; +an illegal or shady scheme or maneuver; +willing or ready to proceed; +of or relating to the game; +to be a gnome; +to manipulate, exploit, or cheat in a system slyly or dishonestly for personal gain; +to pursue for food or in sport; +to attempt to find something; +to express indirectly; +to involve or indicate by inference, association, or necessary consequence rather than by direct statement; +to contain, potentially; +to endure bravely or quietly; +trans rights; +to promote the interests or the cause of; +to uphold or defend as valid or right; +to pay the costs of; +to hold up or serve as a foundation or prop for; +to keep from fainting, yielding, or losing courage; +the act or process of supporting; +having no taste; +not having or exhibiting good taste; +arousing no interest; to analyze the arrangement and connection of words in a sentence or sentence part; to understand or explain the sense or intention of usually in a particular way or with respect to a given set of circumstances; to construe a sentence or sentence part especially in connection with translating; diff --git a/src/lipu_nimi.rs b/src/lipu_nimi.rs index 2c3be74..29d51a3 100644 --- a/src/lipu_nimi.rs +++ b/src/lipu_nimi.rs @@ -1,11 +1,33 @@ - -pub fn pana(i: usize, j: usize) -> Vec { - let lipu_nimi = std::fs::read_to_string("nimi_ale.txt").unwrap(); //o lukin e lipu pi nimi ale - let mut kulupu_nimi = Vec::new(); - for nanpa in i..j+1 { //ijo kepeken li pana e nanpa la, - for nimi in lipu_nimi.lines().nth(nanpa).unwrap().split_whitespace() { - kulupu_nimi.push(String::from(nimi)); //o pana e nimi pi nanpa ni +use rand::seq::SliceRandom; +pub fn pana_lipu(i: usize, j: usize) -> Vec { + let lipu_nimi = std::fs::read_to_string("nimi_ale.txt").unwrap(); + let mut kulupu_nimi = Vec::new(); + for nanpa in i..j+1 { + for nimi in lipu_nimi.lines().nth(nanpa).unwrap().split_whitespace() { + kulupu_nimi.push(String::from(nimi)); } } - kulupu_nimi //pana + kulupu_nimi +} + +pub fn pana(i: &[usize]) -> String { + let lipu_nimi = std::fs::read_to_string("nimi_ale.txt").unwrap(); + let mut kulupu_nimi = Vec::new(); + for nanpa in i { + for nimi in lipu_nimi.lines().nth(*nanpa).unwrap().split_whitespace() { + kulupu_nimi.push(String::from(nimi)); + } + } + String::clone(kulupu_nimi.choose(&mut rand::thread_rng()).unwrap()) +} + +pub fn pana_lili(i: &[usize]) -> char { + let lipu_nimi = std::fs::read_to_string("nimi_ale.txt").unwrap(); + let mut kulupu_nimi = Vec::new(); + for nanpa in i { + for nimi in lipu_nimi.lines().nth(*nanpa).unwrap().split_whitespace() { + kulupu_nimi.push(nimi.chars().nth(0).unwrap()); + } + } + *kulupu_nimi.choose(&mut rand::thread_rng()).unwrap() } diff --git a/src/nimi_sin.rs b/src/nimi_sin.rs index cb19cb3..e58d15d 100644 --- a/src/nimi_sin.rs +++ b/src/nimi_sin.rs @@ -1,5 +1,4 @@ use rand::Rng; -use rand::seq::SliceRandom; use crate::lipu_nimi; pub fn pali(i: u8) -> String { @@ -14,9 +13,9 @@ pub fn pali(i: u8) -> String { let mut nimi: char; if rand::random() || x > 0 { //kipisi 1 la nimi ni li ken lon li ken lon ala. kipisi mute la nimi ni li wile lon if nimi_pini == 'n' { - nimi = nimi_tan(3,3); + nimi = lipu_nimi::pana_lili(&[3]); } else { - nimi = nimi_tan(3,4); + nimi = lipu_nimi::pana_lili(&[3,4]); } nimi_sin.push(nimi); nimi_pini = nimi; @@ -24,13 +23,11 @@ pub fn pali(i: u8) -> String { //o wuwojiti ala if nimi_pini == 'w' { - //ni li nasa a - nimi = *Vec::from([nimi_tan(5,5), nimi_tan(7,7)]) - .choose(&mut rand::thread_rng()).unwrap(); - } else if nimi_pini == 'j' { - nimi = nimi_tan(5,6); + nimi = lipu_nimi::pana_lili(&[5,7]); + } else if nimi_pini == 'j' || nimi_pini == 't' { + nimi = lipu_nimi::pana_lili(&[5,6]); } else { - nimi = nimi_tan(5,7); + nimi = lipu_nimi::pana_lili(&[5,6,7]); } nimi_sin.push(nimi); if rand::thread_rng().gen_range(0..10) == 0 { //nimi n li ken lon. TENPO KAMA LA mi ken wile e ni: nimi n li lon la, ante li lon ala. ante li lon la, nimi n li lon ala @@ -40,14 +37,8 @@ pub fn pali(i: u8) -> String { nimi_pini = nimi; x += 1; } - if lipu_nimi::pana(0,2).contains(&nimi_sin) { //nimi sin li sin ala la, o pali sin e nimi + if lipu_nimi::pana_lipu(0,2).contains(&nimi_sin) { //nimi sin li sin ala la, o pali sin e nimi return pali(i) } nimi_sin //o pana e nimi sin } - -fn nimi_tan(i: usize, j: usize) -> char { //ni li pana e nimi tan linja lon lipu - let kulupu_nimi = lipu_nimi::pana(i,j); - kulupu_nimi.choose(&mut rand::thread_rng()).unwrap().chars().nth(0).unwrap() -} - diff --git a/src/toki.rs b/src/toki.rs index 46dd06e..cfcb27d 100644 --- a/src/toki.rs +++ b/src/toki.rs @@ -1,21 +1,14 @@ use rand::Rng; -use rand::seq::SliceRandom; use crate::lipu_nimi; pub fn pali(nimi_sin: &str) -> String { - let mut toki = String::new(); - toki = pali_lili(toki, nimi_sin, true, false); //ilo li pali e toki la nimi "la" li ken lon la nimi sin li lon ala - toki //ilo li pana e toki - + pali_lili(nimi_sin, true, false) //ilo li pali e toki la nimi "la" li ken lon la nimi sin li lon ala } -fn pali_lili(toki: String, nimi_sin: &str, la_li_ken: bool, nimi_sin_li_lon_a: bool) -> String { - let nimi_pi_ku_suli = lipu_nimi::pana(0,1); - let nimi_tawa = lipu_nimi::pana(1,1); - - let mut toki_sin = String::clone(&toki); +fn pali_lili(nimi_sin: &str, la_li_ken: bool, nimi_sin_li_lon_a: bool) -> String { + let mut toki_sin = String::new(); let mut mi_anu_sina = false; let mut la_anu_seme = rand::thread_rng().gen_range(0_u8..10) == 0; if la_li_ken == false { @@ -36,7 +29,7 @@ fn pali_lili(toki: String, nimi_sin: &str, la_li_ken: bool, nimi_sin_li_lon_a: b toki_sin.push_str("e "); //nimi "e" } if x == 3 { - toki_sin.push_str(nimi_tawa.choose(&mut rand::thread_rng()).unwrap()); //nimi sama nimi "kepeken" + toki_sin.push_str(lipu_nimi::pana(&[1]).as_str()); //nimi sama nimi "kepeken" toki_sin.push_str(" "); } let mut y = 0; @@ -46,15 +39,15 @@ fn pali_lili(toki: String, nimi_sin: &str, la_li_ken: bool, nimi_sin_li_lon_a: b suli_kipisi = rand::thread_rng().gen_range(1_u8..4); //kipisi la nimi tu tu li ken lon } while y < suli_kipisi { - let nimi_ni = nimi_pi_ku_suli.choose(&mut rand::thread_rng()).unwrap(); - if (nimi_ni.as_str().eq("mi") || nimi_ni.as_str().eq("sina")) && suli_kipisi == 1 { + let nimi_ni = lipu_nimi::pana(&[0,1]); + if (nimi_ni == "mi" || nimi_ni == "sina") && suli_kipisi == 1 { mi_anu_sina = true; //nimi li nimi "mi" taso anu nimi "sina" taso } if (rand::thread_rng().gen_range(0_u8..4) == 0 || (x == suli-1 && y == suli_kipisi-1)) && !nimi_sin_li_lon { toki_sin.push_str(nimi_sin); //ilo li pana e nimi sin. nimi_sin_li_lon = true; //ni la, nimi sin li lon! } else { - toki_sin.push_str(nimi_ni); + toki_sin.push_str(nimi_ni.as_str()); } toki_sin.push_str(" "); y += 1; @@ -66,7 +59,7 @@ fn pali_lili(toki: String, nimi_sin: &str, la_li_ken: bool, nimi_sin_li_lon_a: b } if la_anu_seme { toki_sin.push_str("la "); - toki_sin.push_str(pali_lili(String::new(), nimi_sin, false, nimi_sin_li_lon).as_str()); //nimi "la" li lon la, ilo li pali e toki sin li pana e toki ni + toki_sin.push_str(pali_lili(nimi_sin, false, nimi_sin_li_lon).as_str()); //nimi "la" li lon la, ilo li pali e toki sin li pana e toki ni } toki_sin //ilo li pana e toki }