def test_when_can_remove_some_subphrases_then_some_removed(self): counter = ngb.Counter({ "apple": 2, "apple core": 1, "core removal": 1, "apple core removal tool": 1, }) counter.remove_subphrases() self.assertEqual(counter, {"apple": 2, "apple core removal tool": 1})
def test_when_cannot_remove_subphrases_then_none_removed(self): counter = ngb.Counter({ "apple": 4, "apple core": 3, "apple core removal": 2, "apple core removal tool": 1, }) counter.remove_subphrases() self.assertEqual(len(counter.keys()), 4)
def test_when_adding_two_ngrams_then_counts_added(self): counter = ngb.Counter({"apple": 1}) counter.add(ngb.Counter({"apple": 2})) self.assertEqual(counter["apple"], 3)
def test_when_subphrase_appears_within_ngram_then_can_be_removed(self): counter = ngb.Counter({"core": 1, "apple core removal": 1}) counter.remove_subphrases() self.failIf("core" in counter)