diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..eb5a316 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +target diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..bbfe728 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "jttg" +version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..e336027 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "jttg" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..d51102b --- /dev/null +++ b/src/main.rs @@ -0,0 +1,56 @@ +use std::env::args; + +const KNOWN_GRAPHEMES: [&str; 10] = ["a", "i", "u", "e", "o", "ka", "ki", "ku", "ke", "ko"]; + +// look at the first letter, if it exists in KNOWN_GRAPHEMES, then add to graphemes +// else look at the first and second letter, if that exists in KNOWN_GRAPHEMES, then add that to grapehemes +fn split_word(word: String) -> Vec { + let mut graphemes: Vec = vec![]; + let mut word_chars = word.chars(); + let mut grapheme: String; + + loop { + grapheme = match word_chars.next() { + Some(val) => String::from(val), + None => break, + }; + dbg!(&grapheme); + + let temp = grapheme.as_str(); + + if KNOWN_GRAPHEMES.contains(&temp) { + graphemes.push(grapheme); + } else { + grapheme.push(word_chars.next().unwrap()); + + let temp = grapheme.as_str(); + + if KNOWN_GRAPHEMES.contains(&temp) { + graphemes.push(grapheme); + } + } + } + + return graphemes; +} + +fn main() { + // dbg!(KNOWN_GRAPHEMES); + + // dbg!(&args()); + + if args().len() != 2 { + panic!("fuck"); + } + + let input = match args().last() { + Some(val) => val.trim().to_lowercase(), + None => panic!("how?!"), + }; + + println!("Sanitised input: {}", input); + + let graphemes = split_word(input); + + dbg!(graphemes); +}