Correctly compute ngram ratios for queries with less than NGRAM_N characters

parent 8e4856c5
......@@ -394,12 +394,12 @@ where
# rn = toReal n
# annots =
[ 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)
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 (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