def test_count_fail(self): vocabulary = Vocabulary() for sentence in TOKENIZED_CORPUS: vocabulary.add_tokenized_text(sentence) with self.assertRaises(ValueError): vocabulary.truncate_by_min_freq(2)
def test_min_freq(self): vocabulary = Vocabulary() for sentence in TOKENIZED_CORPUS: vocabulary.add_tokenized_text(sentence) vocabulary.truncate_by_min_freq(2) self.assertTrue("walrus" in vocabulary) self.assertFalse("colorless" in vocabulary)