有几个包罗象票价比(
>>> corpus = "Tom bougt hod dog. Jimmy ate hot dog. They like hot dog.".split()
现在,我想理解一下,如何将《LLR》换成文中的话,并找到可能复杂的字句,这里是hot dog
。 我发现<代码>LLR的方程式,并写上了<3>x”的功能,但我不知道<代码>a, b, c, d。 这是我迄今为止所尝试的:
import math
def loglikelihoodratio(a, b, c, d):
result = 2 * (a * math.log(a) + b * math.log(b) + c * math.log(c)
+ d * math.log(d)
- (a + b) * math.log(a + b) - (a + c) * math.log(a + c)
- (b + d) * math.log(b + d) - (c + d) * math.log(c + d)
+ (a + b + c + d) * math.log(a + b + c + d))
return result
<代码>a、b、c、d? 你的友好帮助确实受到赞赏。
Edit: I got the equation from a book which is mentioned in the comments below. Here is a snapshot of the equation.