Verified Commit 7563b05f authored by Camil Staps's avatar Camil Staps 🙂

Correctly compute ngram ratios for queries with less than NGRAM_N characters

parent 8e4856c5
...@@ -394,12 +394,12 @@ where ...@@ -394,12 +394,12 @@ where
# rn = toReal n # rn = toReal n
# annots = # annots =
[ MatchingNGramsQuery (rn / qsize) [ MatchingNGramsQuery (rn / qsize)
, MatchingNGramsResult (rn / toReal (length $ 'NGrams'.ngrams NGRAMS_CI NGRAMS_N name)) , MatchingNGramsResult (rn / toReal (max 1 $ length $ 'NGrams'.ngrams NGRAMS_CI NGRAMS_N name))
] ]
= ((idx, annots), db) = ((idx, annots), db)
cs = [c \\ c <-: s] cs = [c \\ c <-: s]
qsize = toReal $ length $ 'NGrams'.ngrams NGRAMS_CI NGRAMS_N s qsize = toReal $ max 1 $ length $ 'NGrams'.ngrams NGRAMS_CI NGRAMS_N s
syntaxSearch :: CloogleEntry -> (Bool, [a]) syntaxSearch :: CloogleEntry -> (Bool, [a])
syntaxSearch (SyntaxEntry se) = (any (not o isEmpty o flip match cs) se.syntax_patterns, []) syntaxSearch (SyntaxEntry se) = (any (not o isEmpty o flip match cs) se.syntax_patterns, [])
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment