请帮助破译这个 lisp 摘录

发布于 2024-09-30 06:44:55 字数 307 浏览 5 评论 0原文

(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)))))))))
(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)))))))))

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

伴梦长久 2024-10-07 06:44:55

问题是什么?这几乎是简单的英语:

g 为哈希表 goodword 的值(如果不存在则为 0)乘以 2

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

和 < code>b 哈希表 badword 的值(如果不存在则为 0)。

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

考虑到这一点,并假设 gb 之和不小于 5,

   (unless (< (+ g b) 5)

则返回最大值 0.01 或

     (max .01

最小值 0.99 或

          (min .99 

b/nbad 除以 b/nbadg/之和ngood(作为浮点值,这些单独的商最多应为 1)。

               (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)))))))))
愿得七秒忆 2024-10-07 06:44:55

看起来它正在尝试根据哈希表 goodbad 中是否存在 word 来计算分数。

如果该单词不存在于哈希表中,则其值为 0;否则,如果该单词存在于好表中,则其权重为 2(加倍)。

如果分数小于 5,请按如下方式计算分数(除非 以下的部分):

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

我不确定 ngoodnbad 是什么,但是那么 n 向我表明它们可能是计数。代码看起来也将计算出的分数保持在 5 以下。在分数计算中,分母也将保持在最大值 2,并将分数的下限保持在 0.5。

根据您使用的标签,我猜测(这只是猜测)它正在尝试根据好与坏电子邮件中单词的某种频率(?)计数来计算单词的权重。

Looks like it is trying to calculate a score based on the presence of word in the the hash tables good and bad.

If the word does not exist in a hash table it is given a value of 0, otherwise if it exists in the good table it is weighted by 2 (doubled).

If the score is less than 5 calculate the score (portion below unless) as follows:

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

I'm not sure what ngood and nbad are but then n indicates to me they are probably counts. It also looks like the code is keeps the calculated score below 5. It also looks like in the score calculation the denominator will be kept to a maximum 2 keep the lower bound of the score to 0.5.

Based on the tags you've used, I would guess (and it is just a guess) that it is trying to calculate a weighting for word based on some kind of frequency(?) counting of the word in good versus bad email.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文