Small code cleanup

This commit is contained in:
Loïc Lecrenier 2023-03-09 15:53:59 +01:00
parent 78b9304d52
commit 9ec9c204d3
2 changed files with 8 additions and 9 deletions

View File

@ -80,7 +80,7 @@ pub fn word_derivations(
word: &str, word: &str,
max_typo: u8, max_typo: u8,
is_prefix: bool, is_prefix: bool,
) -> Result<WordDerivations> { ) -> Result<Interned<WordDerivations>> {
let fst = ctx.index.words_fst(ctx.txn)?; let fst = ctx.index.words_fst(ctx.txn)?;
let word_interned = ctx.word_interner.insert(word.to_owned()); let word_interned = ctx.word_interner.insert(word.to_owned());
@ -185,7 +185,7 @@ pub fn word_derivations(
}) })
.collect(); .collect();
Ok(WordDerivations { let interned = ctx.derivations_interner.insert(WordDerivations {
original: ctx.word_interner.insert(word.to_owned()), original: ctx.word_interner.insert(word.to_owned()),
synonyms, synonyms,
split_words, split_words,
@ -193,7 +193,9 @@ pub fn word_derivations(
one_typo: one_typo.into_boxed_slice(), one_typo: one_typo.into_boxed_slice(),
two_typos: two_typos.into_boxed_slice(), two_typos: two_typos.into_boxed_slice(),
use_prefix_db, use_prefix_db,
}) });
Ok(interned)
} }
/// Split the original word into the two words that appear the /// Split the original word into the two words that appear the
@ -342,9 +344,7 @@ pub fn located_query_terms_from_string<'search>(
let word = token.lemma(); let word = token.lemma();
let derivations = word_derivations(ctx, word, nbr_typos(word), false)?; let derivations = word_derivations(ctx, word, nbr_typos(word), false)?;
let located_term = LocatedQueryTerm { let located_term = LocatedQueryTerm {
value: QueryTerm::Word { value: QueryTerm::Word { derivations },
derivations: ctx.derivations_interner.insert(derivations),
},
positions: position..=position, positions: position..=position,
}; };
located_terms.push(located_term); located_terms.push(located_term);
@ -355,9 +355,7 @@ pub fn located_query_terms_from_string<'search>(
let word = token.lemma(); let word = token.lemma();
let derivations = word_derivations(ctx, word, nbr_typos(word), true)?; let derivations = word_derivations(ctx, word, nbr_typos(word), true)?;
let located_term = LocatedQueryTerm { let located_term = LocatedQueryTerm {
value: QueryTerm::Word { value: QueryTerm::Word { derivations },
derivations: ctx.derivations_interner.insert(derivations),
},
positions: position..=position, positions: position..=position,
}; };
located_terms.push(located_term); located_terms.push(located_term);

View File

@ -150,6 +150,7 @@ pub fn resolve_query_graph<'search>(
phrase_interner, phrase_interner,
derivations_interner, derivations_interner,
query_term_docids, query_term_docids,
..
} = ctx; } = ctx;
// TODO: there is a faster way to compute this big // TODO: there is a faster way to compute this big
// roaring bitmap expression // roaring bitmap expression