mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-12-23 05:00:06 +01:00
feat: Implement a better automaton builder
This new implementation only allows the last word of a query string to be a prefix.
This commit is contained in:
parent
916b46c839
commit
d8cfac914a
@ -17,8 +17,12 @@ use crate::rank::Document;
|
||||
|
||||
fn split_whitespace_automatons(query: &str) -> Vec<DfaExt> {
|
||||
let mut automatons = Vec::new();
|
||||
for query in query.split_whitespace().map(str::to_lowercase) {
|
||||
let lev = automaton::build_prefix_dfa(&query);
|
||||
let mut words = query.split_whitespace().map(str::to_lowercase).peekable();
|
||||
while let Some(word) = words.next() {
|
||||
let lev = match words.peek() {
|
||||
Some(_) => automaton::build_dfa(&word),
|
||||
None => automaton::build_prefix_dfa(&word),
|
||||
};
|
||||
automatons.push(lev);
|
||||
}
|
||||
automatons
|
||||
|
Loading…
x
Reference in New Issue
Block a user