INNER CODE UNIT · Rust
search
rlaope/estudy · site/graph/crates/graph-wasm/src/lib.rs:188
pub fn search(query: &str) -> Vec<u32> {
let q: String = query.to_ascii_lowercase();
let q = q.trim();
if q.is_empty() {
return Vec::new();
}
let q_tight: String = q.chars().filter(|c| !c.is_whitespace()).collect();
let q_cho = to_choseong(&q_tight);
let q_is_jamo = q_tight
.chars()
.all(|c| is_jamo(c) || c.is_ascii_alphanumeric());
let q_has_syl = has_syllable(q);
let tokens: Vec<&str> = q.split_whitespace().collect();
G.with(|g| {
let g = g.borrow();
let mut hits: Vec<(u32, u32)> = Vec::new(); // (score, id)
for (i, node) in g.nodes.iter().enumerate() {