Beispiel #1
0
def pspam(fn):
    queue = PythonLabs.SpamLab.WordQueue(15)
    p_good, p_bad = spamicity.load_dicts()
    for line in open(fn):
        for word in tokenize(line):
            p = spamicity.conditional_spam(word, p_good, p_bad)
            if p is not None:
                p2.append((word, p))
                queue.insert(word, p)

    return PythonLabs.SpamLab.combined_probability(queue)
Beispiel #2
0
def pspam(fn):
    queue = PythonLabs.SpamLab.WordQueue(15)
    p_good, p_bad = spamicity.load_dicts()
    for line in open(fn):
        for word in tokenize(line):
            p = spamicity.conditional_spam(word, p_good, p_bad)
            if p is not None:
                p2.append((word, p))
                queue.insert(word, p)

    return PythonLabs.SpamLab.combined_probability(queue)
Beispiel #3
0
def prob_spam(email_file_path):
    q = []
    p_good, p_bad = spamicity.load_dicts()

    assert p_good['looking'] == 0.0530

    with open(email_file_path) as f:
        #read each line, tokenize, add to queue with spamicity
        for line in f:
            words = tokenize(line)
            for word in words:
                prob = spamicity.conditional_spam(word, p_good, p_bad)
                #print('word: {} prob: {}'.format(word, prob))
                if prob is not None:
                    p1.append((word, prob))
                    heapq.heappush(q, (prob, words))

    return combine_probs(q)
Beispiel #4
0
def prob_spam(email_file_path):
    q = []
    p_good,p_bad = spamicity.load_dicts()

    assert p_good['looking'] == 0.0530

    with open(email_file_path) as f:
        #read each line, tokenize, add to queue with spamicity
        for line in f:
            words = tokenize(line)
            for word in words:
                prob = spamicity.conditional_spam(word,p_good,p_bad)
                #print('word: {} prob: {}'.format(word, prob))
                if prob is not None:
                    p1.append((word, prob))
                    heapq.heappush(q,(prob, words))

    return combine_probs(q)