def run(environ, start_response): request = Request(environ) ham_phrases = Formatter(request.form['ham'], "\n").run_all() spam_phrases = Formatter(request.form['spam'], "\n").run_all() test_phrase = request.form['test'] classifier = Bayeser(ham_phrases, spam_phrases, test_phrase) result = classifier.classify() start_response("200 OK", [ ("Content-Type", "text/plain"), ("Content-Length", str(len(result))) ]) return iter([result])
def test_ham(self): test_words = 'african american bieber cool artist jazz' bayeser = Bayeser(self.ham_words, self.spam_words, test_words) expect(bayeser.classify()).to.equal('ham')