feat: tantivy lexical index over Alpha-ID texts
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
use alpha_id::lexical::LexicalIndex;
|
||||
use alpha_id::model::AlphaIdEntry;
|
||||
|
||||
fn entry(id: &str, code: &str, text: &str) -> AlphaIdEntry {
|
||||
AlphaIdEntry {
|
||||
alpha_id: id.into(), valid: true,
|
||||
icd_primary: code.into(), icd_star: "".into(), icd_addon: "".into(),
|
||||
icd_primary2: "".into(), orpha: "".into(), text: text.into(),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn finds_entry_by_fuzzy_query() {
|
||||
let entries = vec![
|
||||
entry("I1", "E11.9", "Diabetes mellitus Typ 2"),
|
||||
entry("I2", "I10.90", "Arterielle essentielle Hypertonie"),
|
||||
];
|
||||
let idx = LexicalIndex::build_in_ram(&entries).unwrap();
|
||||
let hits = idx.search("diabetes typ 2", 5).unwrap();
|
||||
assert!(!hits.is_empty());
|
||||
assert_eq!(hits[0].0, 0); // entry index 0
|
||||
assert!(hits[0].1 > 0.0); // bm25 score
|
||||
}
|
||||
Reference in New Issue
Block a user