mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-27 04:25:06 +08:00
review changes
This commit is contained in:
parent
d0aabde502
commit
7541ab99cd
@ -18,6 +18,3 @@ opt-level = 3
|
|||||||
opt-level = 3
|
opt-level = 3
|
||||||
[profile.test.build-override]
|
[profile.test.build-override]
|
||||||
opt-level = 3
|
opt-level = 3
|
||||||
|
|
||||||
[patch.crates-io]
|
|
||||||
fst = { path = "/Users/mpostma/Documents/code/rust/fst/" }
|
|
||||||
|
@ -294,24 +294,18 @@ pub fn word_derivations<'c>(
|
|||||||
let word = std::str::from_utf8(word)?;
|
let word = std::str::from_utf8(word)?;
|
||||||
derived_words.push((word.to_string(), 0));
|
derived_words.push((word.to_string(), 0));
|
||||||
}
|
}
|
||||||
} else {
|
} else if fst.contains(word) {
|
||||||
let automaton = Str::new(word);
|
derived_words.push((word.to_string(), 0));
|
||||||
let mut stream = fst.search(automaton).into_stream();
|
|
||||||
while let Some(word) = stream.next() {
|
|
||||||
let word = std::str::from_utf8(word)?;
|
|
||||||
derived_words.push((word.to_string(), 0));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if max_typo == 1 {
|
if max_typo == 1 {
|
||||||
let dfa = build_dfa(word, 1, is_prefix);
|
let dfa = build_dfa(word, 1, is_prefix);
|
||||||
let starts = Str::new(get_first(word)).starts_with();
|
let starts = Str::new(get_first(word)).starts_with();
|
||||||
let mut stream = fst.search_with_state(starts.intersection(&dfa)).into_stream();
|
let mut stream = fst.search(starts.intersection(&dfa)).into_stream();
|
||||||
|
|
||||||
while let Some((word, state)) = stream.next() {
|
while let Some(word) = stream.next() {
|
||||||
let word = std::str::from_utf8(word)?;
|
let word = std::str::from_utf8(word)?;
|
||||||
let distance = dfa.distance(state.1);
|
derived_words.push((word.to_string(), 1));
|
||||||
derived_words.push((word.to_string(), distance.to_u8()));
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let starts = Str::new(get_first(word)).starts_with();
|
let starts = Str::new(get_first(word)).starts_with();
|
||||||
@ -335,7 +329,7 @@ pub fn word_derivations<'c>(
|
|||||||
fn get_first(s: &str) -> &str {
|
fn get_first(s: &str) -> &str {
|
||||||
match s.chars().next() {
|
match s.chars().next() {
|
||||||
Some(c) => &s[..c.len_utf8()],
|
Some(c) => &s[..c.len_utf8()],
|
||||||
None => s,
|
None => panic!("unexpected empty query"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -366,8 +366,6 @@ fn create_query_tree(
|
|||||||
let mut operations = synonyms(ctx, &words)?.unwrap_or_default();
|
let mut operations = synonyms(ctx, &words)?.unwrap_or_default();
|
||||||
let concat = words.concat();
|
let concat = words.concat();
|
||||||
let query = Query { prefix: is_prefix, kind: typos(concat, true, 1) };
|
let query = Query { prefix: is_prefix, kind: typos(concat, true, 1) };
|
||||||
// let query =
|
|
||||||
// Query { prefix: is_prefix, kind: typos(concat, authorize_typos) };
|
|
||||||
operations.push(Operation::Query(query));
|
operations.push(Operation::Query(query));
|
||||||
and_op_children.push(Operation::or(false, operations));
|
and_op_children.push(Operation::or(false, operations));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user