def predict(file_name): """predict for the given file name.""" model = classifier.train() with open(file_name, 'r') as f: return classifier.classify(f.read(), model)
def test_train(): model = classifier.train() p_go_given_token = model.p_go_given_token('range') # counts look ok assert model.nall_docs > 400 assert model.nnotgo_docs > 150 assert model.ngo_docs > 150 # probabilities within reasonable bounds assert p_go_given_token > 0.5 assert p_go_given_token < 1.0