Work in progress: It seems like we support synonyms, split and concat words

This commit is contained in:
Clément Renault 2019-11-30 16:53:34 +01:00
parent d17d4dc5ec
commit 902625601a
No known key found for this signature in database
GPG key ID: 0151CDAB43460DAE
9 changed files with 1026 additions and 48 deletions

View file

@ -13,11 +13,11 @@ use crate::database::MainT;
use crate::error::MResult;
use crate::store;
use self::dfa::{build_dfa, build_prefix_dfa};
pub use self::dfa::{build_dfa, build_prefix_dfa};
pub use self::query_enhancer::QueryEnhancer;
use self::query_enhancer::QueryEnhancerBuilder;
pub use self::query_enhancer::QueryEnhancerBuilder;
const NGRAMS: usize = 3;
pub const NGRAMS: usize = 3;
pub struct AutomatonProducer {
automatons: Vec<AutomatonGroup>,
@ -145,7 +145,7 @@ pub fn normalize_str(string: &str) -> String {
string
}
fn split_best_frequency<'a>(
pub fn split_best_frequency<'a>(
reader: &heed::RoTxn<MainT>,
word: &'a str,
postings_lists_store: store::PostingsLists,

View file

@ -143,8 +143,7 @@ impl<S: AsRef<str>> QueryEnhancerBuilder<'_, S> {
// we need to pad real query indices
let real_range = real..real + replacement.len().max(range.len());
let real_length = replacement.len();
self.real_to_origin
.push((real_range, (range.start, real_length)));
self.real_to_origin.push((real_range, (range.start, real_length)));
}
pub fn build(self) -> QueryEnhancer {
@ -162,7 +161,7 @@ pub struct QueryEnhancer {
}
impl QueryEnhancer {
/// Returns the query indices to use to replace this real query index.
/// Returns the query indices that represent this real query index.
pub fn replacement(&self, real: u32) -> Range<u32> {
let real = real as usize;