vortaroboto

Log | Files | Refs | README

commit d8cb5996de8d875d1c3a5f4a763339e3733343fc
parent 442164ee835b3a17bc2063b1c11700bfc0a6207f
Author: tomvig38@gmail.com <tomvig38@gmail.com>
Date:   Mon, 25 Oct 2021 08:03:17 +0000

vere korektu la tablvortojn
Diffstat:
Msrc/main.rs | 24+++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/src/main.rs b/src/main.rs @@ -141,22 +141,24 @@ async fn add_words(frazo: String) { .filter(|vf| vf.partoj.len() > 1) .next() { - // Konstrui la vera vorto - let mut vorto = String::with_capacity(vorto.len()); - let mut last_i = 0; - for (i, p) in vf.partoj.iter().enumerate().take_while(|(_, p)| p.vorto.is_some()) { - vorto.push_str(p.parto.as_str()); - last_i = i; - } + let mut vera_vorto = String::with_capacity(vorto.len()); - if last_i != vf.partoj.len() { - vorto.push('-'); + if vf.partoj.len() > 1 { + // Konstrui la vera vorto + // sen la termnoj + for p in vf.partoj.iter().take_while(|p| p.vorto.is_some()) { + vera_vorto.push_str(p.parto.as_str()); + } + vera_vorto.push('-'); + } else { + // vorto estas la vera, nura, vorto + vera_vorto = vorto.to_owned() } - if let Some(v) = h.get_mut(&vorto) { + if let Some(v) = h.get_mut(&vera_vorto) { *v += 1; } else { - h.insert(vorto.to_owned(), 1); + h.insert(vera_vorto, 1); } } }