pub struct KeywordIndex { /* private fields */ }Expand description
An in-memory keyword index over a set of texts, with the tokenizer and
BM25 scoring (k1 1.2, b 0.75) of v9’s keyword recall, for tools that
search what they’ve already read, without the file open (mnemo inspect). It needs no embedder and works on texts from any format.
It uses tokenizer 2 (TOK-1), so a part of a dotted name matches.
use mnemo_engine::KeywordIndex;
let ix = KeywordIndex::new(["the deploy runs on v0.9.0", "tea, not coffee"]);
assert_eq!(ix.search("v0.9.0", 5)[0].0, 0);
assert!(ix.search("nothing", 5).is_empty());
let ix = KeywordIndex::new(["the repo is mnemo.nosync", "iCloud's copy"]);
assert_eq!(ix.search("nosync", 5)[0].0, 0);
assert_eq!(ix.search("icloud", 5)[0].0, 1);Implementations§
Source§impl KeywordIndex
impl KeywordIndex
Sourcepub fn new<'a>(texts: impl IntoIterator<Item = &'a str>) -> Self
pub fn new<'a>(texts: impl IntoIterator<Item = &'a str>) -> Self
Index texts; a hit’s index is the text’s position here.
Trait Implementations§
Source§impl Clone for KeywordIndex
impl Clone for KeywordIndex
Source§impl Debug for KeywordIndex
impl Debug for KeywordIndex
Auto Trait Implementations§
impl Forget for KeywordIndex
impl Freeze for KeywordIndex
impl Move for KeywordIndex
impl RefUnwindSafe for KeywordIndex
impl Send for KeywordIndex
impl Sync for KeywordIndex
impl Unpin for KeywordIndex
impl UnsafeUnpin for KeywordIndex
impl UnwindSafe for KeywordIndex
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more