[libdazzle] fuzzy: tweak scoring algorithm



commit d3207aa9c9f08d871b1161f23a87fb0cd6ccf2bf
Author: Christian Hergert <chergert redhat com>
Date:   Thu Jun 8 16:08:02 2017 -0700

    fuzzy: tweak scoring algorithm
    
    We will use the last index of the match instead of strlen() to calculate
    the score. This will naturally prefer keywords where the match is early
    on to those where the match is later.
    
    It also happens to reduce the strlen() cost (although that would be
    trivialized by the malloc induced on 32-bit systems for now).

 src/search/dzl-fuzzy-index.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/src/search/dzl-fuzzy-index.c b/src/search/dzl-fuzzy-index.c
index 571e2c7..1769b4a 100644
--- a/src/search/dzl-fuzzy-index.c
+++ b/src/search/dzl-fuzzy-index.c
@@ -498,7 +498,7 @@ _dzl_fuzzy_index_resolve (DzlFuzzyIndex  *self,
     *document_id = entry->document_id;
 
   *priority = (entry->key_id & 0xFF000000) >> 24;
-  *out_score = ((1.0 / 256.0) / (strlen (local_key) + in_score)) + ((255.0 - *priority) / 256.0);
+  *out_score = ((1.0 / 256.0) / (1 + last_offset + in_score)) + ((255.0 - *priority) / 256.0);
 
   return TRUE;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]