aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mikisabate@gmail.com>2025-08-12 09:36:10 +0200
committerMiquel Sabaté Solà <mssola@mssola.com>2025-10-27 10:29:19 +0100
commit6b098702c6f7df5d400b76031618506dbdda02a5 (patch)
treeb168c81c53ac30c04d839b7b4c5c54a93cbdb28b /crates
parent83972171d712c60ddfaeb4a68ef1cfd8c314fc10 (diff)
downloadmihi-6b098702c6f7df5d400b76031618506dbdda02a5.tar.gz
mihi-6b098702c6f7df5d400b76031618506dbdda02a5.zip
Trim word parts on database insert
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
Diffstat (limited to 'crates')
-rw-r--r--crates/cli/src/words.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/crates/cli/src/words.rs b/crates/cli/src/words.rs
index d387f00..ba86041 100644
--- a/crates/cli/src/words.rs
+++ b/crates/cli/src/words.rs
@@ -206,6 +206,7 @@ fn ask_for_word_based_on(enunciated: String, word: Word) -> Result<Word, String>
else {
return Err("abort!".to_string());
};
+ let particle = particle.trim().to_string();
let categories = vec![
Category::Unknown,
@@ -261,6 +262,7 @@ fn ask_for_word_based_on(enunciated: String, word: Word) -> Result<Word, String>
}
_ => None,
};
+ let kind = kind.trim().to_string();
// TODO: refine guess once the inflection is known: select from possible values.
let kind = match category {
@@ -366,7 +368,7 @@ fn ask_for_word_based_on(enunciated: String, word: Word) -> Result<Word, String>
// from it, and insert it into the database.
fn do_create(enunciated: String) -> Result<(), String> {
let mut guess = get_initial_guess(enunciated.as_str());
- guess.enunciated = enunciated.clone();
+ guess.enunciated = enunciated.trim().to_string();
let word = ask_for_word_based_on(enunciated.clone(), guess)?;
match mihi::create_word(word) {