(let ((g (* 2 (or (gethash word good) 0)))
(b (or (gethash word bad) 0)))
(unless (< (+ g b) 5)
(max .01
(min .99 (float (/ (min 1 (/ b nbad))
(+ (min 1 (/ g ngood))
(min 1 (/ b nbad)))))))))
What is the problem? It is almost plain english:
Let g
be the value of word
in the hashtable good
(or 0 if not existent there) times 2
(let ((g (* 2 (or (gethash word good) 0)))
and b
the value of word
in the hashtable bad
(or 0 if not existent there).
(b (or (gethash word bad) 0)))
With this in mind, and under the presumption that the sum of g
and b
is not smaller than 5
(unless (< (+ g b) 5)
return the maximum of either 0.01 or
(max .01
the minimum of either 0.99 or
(min .99
b
/nbad
divided by the sum of b
/nbad
and g
/ngood
(as a float value, and those individual quotients should be at most 1).
(float (/ (min 1 (/ b nbad))
(+ (min 1 (/ g ngood))
(min 1 (/ b nbad)))))))))