aboutsummaryrefslogtreecommitdiff
path: root/src/vector.rs
diff options
context:
space:
mode:
authorNathan Reiner <nathan@nathanreiner.xyz>2023-07-09 22:18:14 +0200
committerNathan Reiner <nathan@nathanreiner.xyz>2023-07-09 22:18:14 +0200
commit7fc3df372f119e8c8706fca8d5b060fc13cea5b4 (patch)
treec3c6944869dca8ec9c892e72f19006d24936305c /src/vector.rs
parent4f0b65f5eab1875edd3d4f547952e49bbc79a54d (diff)
add optioal prioritizer on search
Diffstat (limited to 'src/vector.rs')
-rw-r--r--src/vector.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/vector.rs b/src/vector.rs
index dfd2d71..c058490 100644
--- a/src/vector.rs
+++ b/src/vector.rs
@@ -68,3 +68,16 @@ pub fn scalar_product(a : &FileVector, b : &FileVector) -> u64 {
}
c
}
+
+pub fn match_vector(query : &FileVector, v : &FileVector) -> u64 {
+ let mut c = 0;
+ for (i, x) in query.iter() {
+ let s = x * (v.get(i).unwrap_or(&0));
+ if s == 0 {
+ return 0
+ } else {
+ c += s;
+ }
+ }
+ c
+}