def classify(self, x):
    tmp = {}
    for k in self.d:
        tmp[k] = 0
        for word in x:
            tmp[k] += ((log(self.d[k].getsum()) - log(self.total)) + log(self.d[k].freq(word)))
    (ret, prob) = (0, 0)
    for k in self.d:
        now = 0
        for otherk in self.d:
            now += exp((tmp[otherk] - tmp[k]))
        now = (1 / now)
        if (now > prob):
            (ret, prob) = (k, now)
    return (ret, prob)
def classify(self, x):
    tmp = {}
    for k in self.d:
        tmp[k] = 0
        for word in x:
            tmp[k] += ((log(self.d[k].getsum()) - log(self.total)) + log(self.d[k].freq(word)))
    (ret, prob) = (0, 0)
    for k in self.d:
        now = 0
        for otherk in self.d:
            now += exp((tmp[otherk] - tmp[k]))
        now = (1 / now)
        if (now > prob):
            (ret, prob) = (k, now)
    return (ret, prob)