Help decrypt this lisp extract

(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)))))))))
+3
source share
2 answers

What is the problem? This is almost plain English:

Let it gbe a value wordin the hash table good(or 0 if it does not exist there) 2 times

(let ((g (* 2 (or (gethash word good) 0)))

and the bvalue wordin the hash table bad(or 0 if it does not exist there).

      (b (or (gethash word bad) 0)))

With this in mind, and assuming that the sum gand bnot less than 5

   (unless (< (+ g b) 5)

returns a maximum of 0.01 or

     (max .01

minimum 0.99 or

          (min .99 

b/ nbadis divided by the sum of b/ nbadand g/ ngood(as a floating point value, and these separate coefficients should be no more than 1).

               (float (/ (min 1 (/ b nbad))
                         (+ (min 1 (/ g ngood))   
                            (min 1 (/ b nbad)))))))))
+6

, , word - good bad.

-, 0, , , 2 ().

5, ( unless) :

score = min(1, b/nbad) / (min(1, g/ngood) + min(1, b/nbad))
max(0.01, min(0.99, score))

, ngood nbad, n , , , . , 5. , 2, 0,5.

, , ( ), , (?) .

+2

Source: https://habr.com/ru/post/1772478/


All Articles