mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-29 16:45:30 +08: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> {
|
fn split_whitespace_automatons(query: &str) -> Vec<DfaExt> {
|
||||||
let mut automatons = Vec::new();
|
let mut automatons = Vec::new();
|
||||||
for query in query.split_whitespace().map(str::to_lowercase) {
|
let mut words = query.split_whitespace().map(str::to_lowercase).peekable();
|
||||||
let lev = automaton::build_prefix_dfa(&query);
|
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.push(lev);
|
||||||
}
|
}
|
||||||
automatons
|
automatons
|
||||||
|
Loading…
Reference in New Issue
Block a user